481 Posted Topics
Re: Looks to me like you only read in 2 numbers from your text file. Then you go ahead and start printing out un initialised memory space.... Chris | |
Re: [url]http://www.cprogramming.com/[/url] [url]http://www.cplusplus.com/[/url] [url]http://www.cplusplus.com/reference/[/url] Three nice links thanks will get you started. Chris | |
Re: [icode]srand((unsigned)time(NULL));[/icode] is what most people use if I am correct, I know for sure I have always used it and always will, unless someone puts forward a good argument not to use it. Just remember you only need to call srand() once in your application. Chris | |
Re: When doing this, the method is normally to have aheader file containing the function prototype. A Cpp file containing the function declaration and the a main cpp file that contains your [icode]int main(int argc, char *argv[]){}[/icode] function, etc etc.[code=cplusplus]//example.h #ifndef EXAMPLE_H_ #define EXAMPLE_H_ int myfunc(int, int); #endif[/code][code=cplusplus]//example.cpp #include "example.h" int … | |
Re: [QUOTE=skatamatic;785190]Instead use this: [code=cplusplus] cin.ignore(cin.rdbuf()->in_avail()); cin.get(); [/code][/QUOTE] An even better way would be run it from your console/command prompt! Since it's a "console" application! And DO NOT use [icode]system("PAUSE");[/icode]. Not only is it non-portable, but its also a VERY expensive system call! You should probably read the Sticky "How Do … | |
Re: Well if one was to hide the console window and paint on the main window / active window you could use it in conjunction with something like presentations as a pointing aidor something like that. @marco Thats like saying you should do all DirectX Drawing inside WM_PAINT :) | |
Re: [code=cplusplus]ostream& operator<<(ostream& os, Book& b){ cout<< "Title: " << "\"" << b.title << "\"" << endl; cout<< "Author: " << b.author << endl; cout<< "Genre: " << b.genre << endl; cout<< "Publisher: " << b.publisher << endl; cout<< "Publication Year: " << b.pubyear << endl << endl; return os; }[/code] … | |
Re: Here's some work for you, [url]http://www.cplusplus.com/reference/iostream/stringstream/[/url] [url]http://www.cplusplus.com/reference/iostream/istream/getline.html[/url] [url]http://www.cplusplus.com/reference/stl/vector/[/url] [url]http://www.cprogramming.com/tutorial/lesson3.html[/url] Think that should get you started. Chris | |
Re: [code=cplusplus]encryptedLine += (line.at(pos) + password.at(pos2)); if (pos2 > password.size()) { pos2 = 0; }[/code]You try to retreive the value at pos2 when pos2 is > than password.size() before you reset pos2 to 0. Also the check should be >= or == since if the length of string is 12, then … | |
Re: it's your string stream, you need to clear it before adding more to it. [code=cplusplus]OUTPUT.clear()[/code] Chris | |
Re: [QUOTE=neoangin;796713]omg, I am using Visual C++ 2008 Express Edition "Resource Editiong is not supported on the Visual C++ Express SKU" :( Thanks anyway.[/QUOTE] EDITING is not supported, you can still use .rc files lol, just if you want to use VISUAL resources then you have to make the in external … | |
Re: Can't see exactly what you are doing wrong, partly because i prefer having function definitions split from the class prototypeing. However you have a function [icode]void book()[/icode] now, i'm curious as to what this is supposed to do, since you never call it; yet it looks to me as though … | |
Re: [URL="http://www.letmegooglethatforyou.com/?q=C%2B%2B+DLLs"]One is even on C++ DLLs with VB![/URL] Chris | |
Re: [code=c]void *malloc ( size_t size );[/code]This is the function prototype, and as Agni stated it returns a void pointer. Since this is the function prototype you do not use this syntax when calling the function and infact you use the syntax you originally posted. Here is a small example[code=c]int q … | |
Re: Be sure to make sure all of the files are in the same project, not indervidual just indervidual files, otherwise the compiler will not know to use myfile.c. Chris | |
Re: [code=cplusplus]if(!inClientFile)[/code]Please do not use this method, it is so wrong. You would be better using the following[code=cplusplus]if(!inClientFile.good())[/code]Chris | |
Re: A) We do not do work for you. B) Do not use "Fakse" Signatures C) Do not advertise D) Read the forum rules E) Come back after doing these with a code attempt. Chris | |
Re: You need to make your constructer call for the Movie class match the constructor definition for starters. Your displayInfo() and searchList() functions in there prototype do not state they accept an array of of the structure Movie, but they do in their definitions. Chris | |
Re: Please use [noparse][code=cplusplus][/code][/noparse] tags. You need to learn how to call functions since from what I can see you have no idea. I suggest going over the basics again before attempting to carry on. Chris | |
| |
Re: Read the forum rules, read a C++ book, read previous threads, just read something! Chris | |
Re: Would you not be better of using strings in the modern world of C++ or is this an assignment? Sorry to ask this just don't wanted to go into this method if we can just use strings :) Chris | |
Re: [QUOTE=FrancisC07;792470]for your q1 this is the code that will reverse the digit.. 3 integers, you should modify this to 5 digit.. [CODE]temp=x; x=z; z=y; y=temp;[/CODE][/QUOTE]This is a bad solution, you should not do it this way as this relies on you know A exactly how many digits will be entered … | |
Re: your desciption indicates that you will be given a list of random numbers that will be in no particualr order. thus you cannot just loop through the array backwards. You will need to perform some form of sorting algorithm such as a [URL="http://en.wikipedia.org/wiki/Bubble_sort"]Bubble Sort[/URL] Chris | |
Re: What agni is suggesting is you do something like this, and then do a search on the name for the inputted name and output the corrisponding number.[code=cplusplus]#include <iostream> #include <vector> #include <fstream> #include <string> #include <sstream> using namespace std; struct data{ string name; int number; }; int main(void){ vector<data> FileData; … | |
Re: should be [icode]static char *month[12][25];[/icode] Chris | |
Re: Think about all the things you have been taught in you're course so far. Think about where you excel in programming then develop smaller projects you have already completed into a monster project. That way you won't be wondering completely into the dark.... Chris | |
Re: [icode]char name[5];[/icode] 5 is the number of elements you get 0..4 Chris | |
Re: crazyness but [code=cplusplus]fsync(fileObject.rdbuf())[/code] would it not be something silly like that? EDIT: Nevermind previous was a much better answer[/EDIT] | |
Re: Re-word: He like many others does not trust exectuables presented to them from foreign, unknown sources on a programming website. | |
Re: I'm guessing from the PM you sent me, before creating this thread you found my code snippets. Why don't you look at those as a starting point. Also why didn't you follow the poliate adive I gave you of posting your attempt? Since it is rare i respond to PM's | |
Re: You could use [URL="http://www.cppreference.com/wiki/io/sstream/start"]stringstreams[/URL] to convert the string into an integer. Or you could use atoi() or even better strtol() you can research all of these on the nternet, they are all well documented, if you are still stuck then get back to us. (String streams would be the best … | |
Re: Post a sample of your input file and a sample of what your output should be, and what output you are getting please. Chris | |
Re: [code=cplusplus]#include <fstream> #include <string> int main(int argc, char *argv[]){ std::string example = "Hello, world!\nHow are you?\n\tSuper thanks!"; std::ofstream exfile("test.txt"); if(!exfile.good()) return 0; exfile << example; exfile.close(); return 0; }[/code]I see no whitespace problem...[code=test.txt]Hello, world! How are you? Super thanks![/code]Chris | |
Re: You could always write your own implementation....that way it would only use things avaliable to you in the STL Chris | |
Re: Do some research on google, then come back with yuor findings and we will spread some more light on it, but it sounds to me like a homework question and you are looking for a copy and paste answer! Chris | |
Re: You may find this helpful [url]http://www.voidspace.org.uk/python/movpy/movableidle.html[/url] Chris | |
Re: You're still calling srand() more than once. Also try indenting your code and you might see your problem! Or at least stand a chance, thats too painful to try and read tbh. Chris | |
Re: [code=cplusplus]if (h < 0) { return 1; // error code +1 = underflow hours } else if( h > 59 ) { return 2; // error code +2 = overflow hours }[/code]:) | |
Re: [url]http://msdn.microsoft.com/en-us/library/aa364946(VS.85).aspx[/url] :) or you could probably count the number of characters in the file in binary mode the multiple it by 8?? | |
Re: please don't use TEX tags, just do number%10000000 Chris | |
Re: You can check out the [URL="http://msdn.microsoft.com/en-us/library/aa383749(VS.85).aspx"]Win32 Reference at MSDN[/URL] too. You might find these links quite nice though. [url]http://www.winprog.org/tutorial/[/url] <-- Very well known [url]http://www.relisoft.com/win32/index.htm[/url] <-- Highly vetted for Chris | |
Re: You should have all prototypes in the header file and the full function delarations in the external file. Chris | |
Re: please use [noparse][code=language][/code][/noparse] tags. This is possible, create a string with the path and extension such as this [code=cplusplus]string path = "C:\\"; path += (rand()%5+1)+'0'; path += ".jpg";[/code]Build your entire system expression like that, and then pass it like this [icode]system(path.c_str())[/icode] Chris | |
| |
Re: I would do something like this, [code=cplusplus]#include <iostream> #include <string> #include <sstream> #include <vector> #include <fstream> using namespace std; struct cell{ int value; string pos; }cellData; int main(void){ ifstream ins("example.txt"); if(!ins.good()) return 0; vector<cell> data; string line; istringstream iss; while(getline(ins, line)){ for(int i = 0; i < line.length(); i++) if(line[i] … | |
Re: Perhaps we could welcome him to the world of C++, rather than staying in the dark ages of C. Vectors, as have already been suggested would be a better approach....as would stringstreams.[code=cplusplus]#include <iostream> #include <fstream> #include <vector> #include <sstream> #include <string> using namespace std; int main(void){ ifstream data("test.dat", ios::in); string … | |
Re: Sounds to me like you need to do some work yourself. I'd start by Googling Permutations. Chris | |
Re: I'd think about how to check if a file is really open :) | |
Re: So [code=cplusplus]if(result > 99999) return 0;[/code] *mumbles about multiple exit points* Chris |
The End.