15,300 Posted Topics
Re: >>Am i doing it right? No. The code you posted will try to read the last line of the file twice. [code] ifstream in("inpufile.txt"); ofstream out("newfile.txt"); while( getline (in, str1) ) { out << str1 << '\n'; } [/code] >> And will this work on MFC project? Yes | |
Re: The C and C++ standards dictate how compilers do things. And the standards say that main() must return an integer value to the operating system. That always happens even in you decide to declare main() return void or even something else such as char*. One reason for that is to … | |
Re: MSDN is free at [url]www.microsoft.com[/url] and can not be downloaded. If you need a local version you have to buy it for about a thousand $$$. | |
Re: Piracy is illegal. period. Its the same as stealing money from someone. If you have a job would you like it if someone else was paid for the hours that you worked ? >>On the other hand, those who practice/support piracy say that the original product is too expensive to … | |
Re: I'm sure the OP will thank you for doing his homework for him, even though it's not 100% correct. But I'll give you a B+ for good effort. | |
Re: >>intset.cpp:16: error: prototype for âIntegerSet::IntegerSet(int*)â does not matc That means the constructor in the *.cpp file says the parameter is an int array, but in the *.h file it says the parameter is a single integer. >>main.cpp:36: error: invalid conversion from âint*â to âintâ Same problem as above. Fix the … | |
Re: No. Turbo C is a C compiler, not c++. Get a modern c/c++ compiler such as Code::Blocks or VC++ 2010 Express, both are free. | |
I get a kick out of reading people's signatures and find many of them funny and witty. Which ones do you like? Here's one I just read :lol: [quote]If a job is 10% inspiration and 90% perspiration, does that mean the job stinks?[/quote] | |
Re: Find out what book your class will require, buy it and study it. Other than that, there are lots of good books, see the [URL="http://www.daniweb.com/forums/thread70096.html"]Stick thread[/URL] about c++ books. | |
Re: you mean like [URL="http://lmgtfy.com/?q=calendar+c+program"]these?[/URL] | |
Re: you have to include <vector> in MyDerivedClass.cxx because its not included in any of the header files you created. | |
Re: You will have to post some of the contents of the file before we can tell you how to convert it. If its somethng like this: [quote] 123 456 789 10 20 [/quote] You can use std::stringstream class to convert it from unsigned char* to an int array after its … | |
Re: There doesn't appear to be an option to add that button. I just use Ctrl+F5 which is nearly as easy as that button. You will find lots of differences between those two compilers. That button is probably the least one to be concerned about. | |
Re: >>is this the right way to do append ofstream? No. Delete line 5 because line 4 opens the file in append mode. Its not writing to the file because of line 5. | |
![]() | Re: did you include <sstring> ? >>? ", " : " }\n"); Split that out into an if statement and see what the compiler says about it. [code] stream << matrix(x, y); if( x < 3 ) stream << ", "; else stream << " )\n"; [/code] ![]() |
Re: see [URL="http://www.dotnet247.com/247reference/msgs/40/202700.aspx"]this thread[/URL] which is the first one listed in [URL="http://www.google.com/search?hl=en&sa=X&oi=spell&resnum=0&ct=result&cd=1&q=Microsoft.Jet.OLEDB.4.0%27+provider&spell=1"]these google links.[/URL] | |
Re: Change the language of your computer to something like Chinese where they read right to left. | |
Re: That's called redirecting stdout to a file. Output to the screen is done with either stdout or stderr (in both C and C++). Another way to do it is for program 2 to create a pipe through which program 1's stdout is redirected through the pipe to program 2. [URL="http://docs.sun.com/app/docs/doc/816-5168/popen-3c?a=view"]Here … | |
Re: You can't really delete an element. All you can do is move the data in higher subscripts to lower ones. For example if you have an array of 10 elements and you want to delete the 2nd one you have to move elements 3 to 10 to elements 2 to … | |
Re: typecasting is always error prone. >>blindly typecasting will result to problems ? "may" cause problems, not will. That's when you have to know what your doing, and even that is no guarentee that a typecast will be correct. | |
Re: A little pseudocode [code] beginning of loop display "Enter your password\n"; get user keyboard input if password is correct then exit this loop if this is the third attempt then exit this program, end of loop [/code] | |
Re: The class destructor is responsible for deallocating memory for those pointers, assuming the memory was allocated using new or malloc(). | |
Re: First figure out how to solve it on paper, then write a program to do it similar way. | |
Re: >>tmp += 2; The first one doesn't work because the program keeps changing the value of temp on every loop iteration. Delete that line and the program will work. | |
Re: use a vector [code] vector<Point> points; Point p; while( inFile >> p.x >> p.y ) { points.push_back(p); } [/code] | |
Re: When a line of text is read from the file check to see if it contains "fr_name". If it does, then extract the name and put it into the vector. [icode]std::vector<std::string> friends;[/icode] | |
Re: getline() in the posted example is probably his own C function because the parameters are incorrect for the c++ version. May I suggest you look in semaphore.h and see if there is a marco you need to define. | |
Re: line 66 of the code you posted: variable size has not been declared line 77: what is [b]Start[/b] ? line 78: you need to use == boolean operator, not = assignment operator | |
Re: Post code. We are not clarvoyant and I don't have my crystal ball with me. | |
Re: What compiler are you using? Your program compiles without error using vc++ 2010 express. And this is the output [quote]3.1400Press any key to continue . . .[/quote] Note that if you want a line feed before Press then you need to add '\n' to the cout statement. | |
Re: >>Does anybody know how I could do this? Yes -- write a probram using VB.NET. If you want a more complete answer you will have to post your question in one of the software support forums, not here in Geek's Lounge. | |
Re: You mean you want to call notepad.exe from your *.cpp program? Then use system() or ShellExecute(). | |
Re: >>So why we can overcome this and create class definition in more than one file? Put the class declaration in a header file with *.h extension and include the header file in all *.cpp files that use it. The implementation code goes only in one *.cpp file. >>Summarize: why it … | |
Re: No. Windows Forms require c++, not C. If your embedded device is running some version of MS-Windows then you might be able to use pure win32 api functions. But if its running *nix then I don't know. | |
Re: I don't see US currency ever merging with Canada's either -- Canada probably doesn't want it because US currency is going the way of Mexico's -- worthless. | |
Re: what are a few of the error messages? What compiler and operating system are you using? It looks like you are attempting to compile pseudo code that your teacher gave you as if it is c/c++ code. You can't do that. You have to translate that pseudocode into c++ code … | |
Re: If the file contains only numbers why are you reading them as strings? [code] float number; while( fsprintf(fp,"%f", &number) > 0) { // do something with number } [/code] | |
Re: >> strcat(s1,s); //giving error while copmiling You can't use strcat on s1 because s1 is std::string. All you need is [icode]s1 += s;[/icode] | |
Re: Declare the struct before any of the classes. | |
Re: line 51: close() does not clear the end-of-file flag. After calling close() call clear() so that indata can be used for subsequent loop iterations. Another way to do it is to move line 18 down so that its inside the loop (line 25). | |
Re: [QUOTE=iceman29;889279]I am working on UNIX, and using CC to compile the code.[/QUOTE] Wouldn't it be terminal dependent? something to do with termcap settings? (Just guessing, its been 15 or so years since I worked with *nix). | |
Re: >>Only using libraries built into Dev-C++ That is a very old and obsolete IDE/compiler. Download Co[URL="http://www.codeblocks.org/"]de::Blocks[/URL] and current MinGW compiler. I'm assuming you are talking about MS-Windows operating system. Then read [URL="http://winprog.org/tutorial/"]this tutorial[/URL] to get you started with GUI. By the time you finish the tutorial you will probably realize … | |
Re: your compiler is correct. print() is not accessible outside Bird class because of private inherentence. It can only be called from within Bird class just like any other private member. | |
Re: line 12: for (i=1; i<=N; i++) Array elements always begin with 0, not with 1. So when that loop reaches N the value of i will be beyond the range of the arrays. The loop should be coded like this: [icode]for( i = 0; i < N; i++)[/icode] >>the program … | |
Re: >>Can anyone give me some tips?? Lots of practice. Learn everything you can about hardware and operating systems. | |
Re: When you downloaded Code::Blocks did you get the version that contains MinGW compiler? | |
Re: Very similar to the way you would do it with printf(), but use sprintf() to format the string in a character array, then send the character array to MessageBox() or whatever win32 api function you want. Note that if your program is compiled for UNICODE then you will have to … | |
Re: Only if the DLL will be used by to C and C++ programs. | |
Re: >> I don't have the time or requirements to download and install everything for Windows CE. It would be greatly appreciated. Nonsense. You have the time to post a requrest here and wait several hours for someone to hopefully give you the *.cpp file. You could have downloaded the entire … |
The End.