15,300 Posted Topics
Re: Create a new project but instead of a console project create a static library, then add the files to it. Or, if the files are small enough just add them to your console project as if you wrote them yourself. That way you don't have to bother making libraries out … | |
Re: IMO you need to stop using Dev-C++ and get Code::Blocks. Code::Blocks is a better IDE, uses newer version of MinGW compiler (g++), and has a better debugger. That will solve your 2nd problem. As for your first problem, why didn't you add the other *.cpp files to the project? | |
Re: lines 24 and 33: is_open() does not take any parameters. line 30: you can not put string literal on that line. You have to replace that string literal with a variable name, something similar to what you did on line 21. There are probably other errors -- I stopped reading … | |
Re: I assume you want to delete a line from a text file, right? In that case all you have to do is completly rewrite the file, omitting the line you want to delete. | |
Re: What data type is [b]date[/b]? Can we assume it is a character array since you want to enter in mm-dd-yyyy format? After entering the date it needs to be split up into month, day and year integers. Then to test for yeap use use the mod operator % on the … | |
Re: if this->name is a pointer (i.e. char*) then you have to allocate space for it before copying the string. Just setting with = as in your example will not work. [code] Name::Name(char* nm){ this->name = new char[strlen(nm)+1); strcpy(this->name,nm); } [/code] >>Ideally i would like to stay away from the use … | |
Re: [QUOTE=cscgal;1055162]No worries ... we always love feedback so anytime you have anything to say, please be my guest ... and know that you're being heard. :)[/QUOTE] Yea, right. Like you [URL="http://www.daniweb.com/forums/thread239524.html"]ignoring this thread[/URL]. | |
Re: Two things wrong with the if statement on lines 120 and 124 1) if statements must have ( and ). e.g. [icode]if( condition )[/icode] 2) = is an assignment operator, == is a boolean logic operator. You want to use == in if statements | |
Re: Not possible to move the mouse without using some lib or function. There are no c functions to do that, nor are there any native MS-DOS assembly language system calls that support the mouse. Your only option is to call one of the mouse device driver's functions, assuming a device … | |
Re: Notice there are four 2-byte entries not just three. So either the format is incorrect or you didn't post the correct file contents. how you read the text might be something like this: [code] char text[255] = {0}; myfile.read(text, msglen); text[msglen] = 0; // null-terminate the string [/code] | |
Re: >>Does this function call and definition not match ? Bingo :) My guess is that you have two overloaded functions named bookinfo, but neither of them have exactly the same arguments as the one your program is attempting to call. Notice that one passes some parameters by reference while the … | |
Re: Of course it can't be deleted because the program has it open. You have to close the file before attempting to delete it. [edit]And what ^^^ said too. | |
Re: Using c++ classes is going to be a little slower than C functions becuase c++ has a little more overhead to contend with. Also make sure your compiler is optimizing the code to use the computer's math coprocessor for floating point math instead of using an emulator library. | |
Re: could be that you didn't add the boost libraries to your program's project. Did you compile them after installing boost? | |
Re: delete them in the opposite order that they were allocated. use [b]delete[/b] inside the loop, but [b]delete[][/b] to delete the array itself. 2) Not possible. You should create another method which can be called after the memory is allocated. | |
Re: You can't really use a switch statement based on averages. Its better to use a series of if statements so that you can gest ranges of values [code] if( average > 90) return 'A'; else if( average > 80 ) return 'B'; // etc etc [/code] | |
Re: It probably doesn't really matter one way or the other, the compiler will probably optimize them both the same. Whether or not to use a pointer should depend on other factors. But consider that pointers are a little more dangerous because programmers often fail to clean up when done with … | |
Re: >>The loop works fine No it doesn't. That loop may read the last line of the file twice, assuming there are fewer than MAXENTRIES number of lines in the file. My guess is that you have just dummied up the code you posted without bothering to copy/paste from the code … | |
Re: edit your post to include code tags [noparse][code] // your code goes here [/code][/noparse] where (which line) does the error occur? | |
Re: you need to typecast the base class pointer into a derived class pointer before it can call functions unique to the derived class. Base class knows nothing about those functions. [icode]derived_class *pDerived = reinterpret_cast<derived_class*>(obj);[/icode] [code] int main(void) { base_class *obj; obj = new derived_class (10); derived_class* pDerived = reinterpret_cast<derived_class*>(obj); obj->func_1(); … | |
Re: Of course if you are curious enough you could ask [URL="http://www.google.com/search?hl=en&q=how+to+write+an+operating+system+in+c&btnG=Google+Search"]google [/URL]your question and study the links it gives you. I found at least a half-dozen articles in just a few seconds. Most universities officer course in operating systems. You might take one of those courses, but you will need … | |
Re: >>line 35: ofile.write((char*)&g[0], sizeof(g[0])); sincfe g[0] is a pointer, sizeof(g[0]) is the same as sizeof(any pointer) which is normally 4 with a 32-bit compiler. What you want there is sizeof(graph). But that won't really do what you want either because it doesn't include the edgenode array other than that array … | |
Re: Here is one way to do it -- use stringstream class [code] #include <sstream> #include <string> #include <iostream> #include <iomanip> using namespace std; int main(int argc, char* argv[]) { int day = 20; int month = 1; int year = 8; stringstream str; str << setw(2) << setfill('0') << year … | |
Re: simple colution [code] int main() { int num; char chars[] = "abcdefghijklmnopqrstuvwxyz"; cout << "How many strings do you want to create?\n"; cin >> num; long n = 0; for(int i = 1; i < num+1; i++) { for(int j = 0; j < i; j++, n++) cout << chars[n%26]; … | |
Re: No you don't have to use () on your own c++ classes. [code] class MyClass { public: MyClass() { cout << "Hello World\n"; } }; int main() { MyClass c; } [/code] | |
Re: You mean like this? [code] void openPasswd(char* users[],char* names[], int maxitems) { } int main(int argc, char* argv[]) { const int MaxItems = 20; char *users[MaxItems] = {0}; char *names[MaxItems] = {0}; openPasswd(users, names, MaxItems); return 0; } [/code] | |
Re: Did you run the vista compatability program? It would have tested the computer's hardware and given you a report of what needs to be fixed. | |
Re: On *nix you can call the function opendir() to check if a directory exists. You can use fopen() to do that. I believe stat() will also work on directories. | |
Re: You trying to create a game? You can use game generators like DirectX or OpenGL (google for them, both are free). You might also want to google for sprites. | |
Re: How do you know Sleep() doesn't work?? Recall the parameter is milliseconds -- there are 1000 milliseconds in one second. | |
Re: [b]which[/b] is not difficult to implement. Just get the environment variable PATH, then check each of the directories for the given file and report the directory for the first hit. The file might be contained in more than one directory, but all you want to report is the first one. … | |
Re: What is the problem? What have you tried to resolve the problem? | |
Re: >>Is it incorrect to pass "hFind" as the first parameter to GetFileTime()? No. You need to read msdn for the functions you want to use. [URL="http://msdn.microsoft.com/en-us/library/ms724320%28VS.85%29.aspx"]Read this[/URL]. It clearly states the hFile parameter must have been obtained by CreateFile(). | |
Re: Compare each string one character at a time in a loop. If one string contains a ? then assume it is matched with whatever character is in the other string. If one character contains a * then look at the next character (in your example its a 'g'), then in … | |
Re: deleted line 12 -- srand() does that. And its in the wrong place too -- it should appear at the top of main() because srand() should only be called once during the lifetime of the program. | |
Re: line 7 and 8 of the read function: Line 8 is unnecessary because line 7 opens the file when the stream is declared. line 12: if lastname never contains spaces then use use >> operator instead of getline(). line 13: doesn't make any sense. [b]names[/b] is an array, but you … | |
Re: [QUOTE=basketball4567;1061785] [B]void main()[/B] just means that the programming doesnt return any value.[/QUOTE] Never ever recommend [b]void[/b] main() because it isn't recognized by either C or C++ standards. [URL="http://users.aber.ac.uk/auj/voidmain.shtml"]Read this article[/URL]. | |
Re: >>sizeof("C:\\Windows\\filenamehere.exe"); That will not produce the value you want -- the sizeof(any pointer here) is the same for all pointers (most likely 4). It would be easier to just declare a variable to hold that string so that you don't have it in your program twice. [icode]char filename[] = "C:\\Windows\\filenamehere.exe";[/icode] … | |
Re: Must mean integers, because there are an infinite quantity of floats or doubles between two numbers. The word [b]amount[/b] is ambiguous. Does it mean [b]sum[/b] or [b]quantity[/b] ? For example, there are 11 numbers betwen 0 and 10, but the sum is 1+2+3...+10 = 55 | |
Re: Read the file sequentially from beginning to end, counting lines as you go along. If you want to read the 2d line then you will have to read lines 1 and 2. It is not possible to skip to a specific line in a text file. | |
Re: what "catch" ? There are lots of them on the computer. You can't get access to most of them because they are part of the os. | |
Re: Here are just a few suggestions: line 46: >> gets(str); Never ever use gets(). What will happen if I enter more characters than the buffer can hold? Answer: Seg Fault. Use fgets() instead because it will limit the input to the max length you want. line 49: has no value … | |
Re: [QUOTE=NicAx64;1061414] as I remember unix files uses \r\n and dos only uses \n. so that's why you get an difference. [/quote] Your memory is a little fuzzy -- its just the opposite. MS-Windows/MS-DOS: \r\n *nix: \n MAC: \r [quote]You will get a extra single character or two depending on you're … | |
Re: [URL="http://www.builderau.com.au/program/java/soa/Writing-complex-interrupt-handlers-in-C/0,339024620,320268033,00.htm"]Here [/URL]is one example of how to do it. I hope you are familiar with assembly language. | |
| |
Re: Read both files at the same time as firstPerson mentioned, then compare the lines as they are read; no need to put them in a vector unless you intend to do something else with them. | |
Re: Of course you can't really delete an element in an array, just shift all remaining array elements up to write over the element you want deleted and leave an empty element at the end of the array. If you have an array with 5 elements and you want to delete … | |
Re: >>Thanks in advance ! Dump vc++ 6.0 -- its old, outdated and does not support c++ very well. Another suggestion: Go to [url]www.winpcap.org[/url], click on their Support link and join their mailing list. Get answers to your questions from the people who should know. | |
Re: Your head is wrapped around it wrong. I don't know how you got 19 mpg -- 160.9/3.27 is 49, not 19. | |
Re: 1) use ifstream, not fstream, to read a file. ifstream is easier to use. 2) use getline() to read an entire line that may or may not contain spaces. [code] ifstream in("test.txt); getline(line1, in); // do the same for the other lines [/code] |
The End.