15,300 Posted Topics
Re: Do I really need to ? I've been a member here since the stone ages.:) | |
Re: Normally overload operators so that you can do mathematical or other operations with c++ classes. for example: [icode]cout << MyClass;[/icode] assuming MyClass is an instance of some c++ class and you want that class to print the value of its class variables to the screen. Or you might want to … | |
Re: You are attempting to treat a <vector> as if it were a <set>, which is not possible. [code] #include <iostream> #include <vector> #include <string> using namespace std; int main() { vector<vector<char>> vset; vector<char> element; vset.resize(255); element.push_back('a'); element.push_back('b'); element.push_back('c'); vset['A'] = element; element[0] = 'e'; element[1] = 'e'; element[2] = 'f'; … | |
Re: >>"(1) how to capture number of occurrences of 3 between 1 to 100? " Write a for loop that counts from 1 to 100. Convert each int value to a string then test the string if it contains a '3'. 2) Do you know how to declare a function pointer? … | |
Re: First, open the file for reading in binary mode. Second, open the output file for writing in binary mode declare an unsigned char array of size 255 create a while loop and continue while reading [code] while( infile.read( buf, sizeof(buf) ) { size_t len = infile.gcount(); // get the number … | |
Re: [code] int main( int argc, char* argv[] ) { char* inputFile; char* outputFile; inputFile = argv[ 1 ]; outputFile = argv[ 2 ]; ifstream in(inputFile); if( in.is_open() ) { ofstream out(outputFile); out << in.rdbuf(); } //ofstream(outputFile) << ifstream(inputFile).rdbuf(); return 0; }[/code] | |
Re: The parameter to [URL="http://msdn.microsoft.com/en-us/library/ms682629%28VS.85%29.aspx"]EnumProcesses[/URL]() is not a function pointer, but a pointer to an array of DWORDs. That link contains a simple example program to demonstrate how it works. | |
Re: There are a couple ways to use SQL databases such as MS-Access. 1)[URL="http://www.google.com/#hl=en&q=odbc+tutorials&aq=f&oq=&aqi=&fp=-Pw1cEIpNGU"] ODBC [/URL]and 2) [URL="http://www.google.com/#hl=en&q=ado+tutorials&aq=f&oq=&aqi=&fp=-Pw1cEIpNGU"]ADO[/URL] Since you didn't bother to tell us what you did or post any code, I'm not going to bother explaining how to do it other than giving you some google links. | |
Re: main() is passing an array of ints to that function, but the function is using it like its a pointer to a single int. >>The code is taken from Dennis Ritchie's "C Programming Language" 's page 97 (2nd Edition). I doubt it -- he is a hell of a lot … | |
A while back when I changed and saved my signature it was changed on every post that I had made. I just now changed it, but nothing happened in existing posts. Was the previous behavior because I was a mod or has something else changed here at DaniWeb ? | |
Re: I was also having problems today setting up NetBeans with MiniWG. Even after installing the MSYS version of make, NetBeans refused to successfully compile a simple Hello World program. So I deleted MiniWG and installed cygwin, and had everything going in about a half hour. I have not tried debugging … | |
Re: You won't get much help by posting all that unformatted code. Learn to use code tags. You still have time -- go back and edit that post to add the tags. | |
Re: Get the input as a string then check each of the characters. If all is ok then convert that string to int (or other data type). Something along these lines. [code] #include <iostream> #include <string> #include <sstream> using namespace std; int main() { int gallons; std::string input; cout << "Enter … | |
Re: That will be too slow. If you are on Windows os then try [URL="http://msdn.microsoft.com/en-us/library/dd183370%28VS.85%29.aspx"]this function[/URL] Or maybe [URL="http://www.codeproject.com/KB/clipboard/hscr2clp.aspx"]this program[/URL]. And I hope you intend to use the same file every time. You will fill up a hard drive pretty quickly if you use a different names. | |
Re: >>anything wrong in the program? 1. its [icode][color=red]int [/color] main().[/icode] 2. Add [icode]return 0;[/icode] as the last line in main() 3. Add '\n' to the end of Hello, making it "Hello\n" 4. You might need to add [icode]fflush(stdout)[/icode] after that print statement. If the above doesn't fix the problem then … | |
Re: Suggest you use getline() to read the entire line, then use stringstream object to split it into words. [code] std::string line; ifstream in("file.txt"); while( getline( in, line) ) { std::string word; stringstream str(line); while( str >> word ) { // now do something with this word } } [/code] As … | |
Re: getch() returns 224, not 0, when an arrow key is pressed. So the program has to check for both values (0 and 224) Also, getch() returns an int, not char. | |
Re: right click on the project name, then select Properties at the bottom of the menu. In the Categories box select Linker, then on the right side click the button with "..." next to "Libraries" (near the bottom) , In the popup window select "Add Library" and there you can add … | |
Re: [QUOTE=PetuniaRose;939155]I see folks replying to threads with quotes that have the name of the original poster included - they have the form nameOfPoster> quote I've been crawling around the faq for the past hour or so, and haven't found any really newbie guides for using all the neat stuff that's … | |
Re: google for "ODBC c++ classes". Then in the OnClick event handler do the sql queries via odbc and fill the listbox or whatever. | |
Re: >>Should I uninstall wxWidgets after buidling? Not unless you never want to use it again. If your computer is running out of space then there are other files that should be removed before wxWidgets, such as all the compiler-generated files. If you are using Microsoft compiler then it will generate … | |
Re: why is that class declared extern "C" ? C programs can't call c++ classes, to that declaration is pointless. | |
Re: I don't have that problem but things are really looking screwy. | |
Re: I'm not a thrill-seeker, never have been. Even a faris wheel scares me when it stops me at the top. | |
Re: This is one of the problems with learning to program with an ancient compiler such as Turbo C -- you don't know the difference between compiler-specific functions and standard C. | |
Re: Forget making games for now and just concentrate on learning the language. You have to learn how to crawl before you can start running. | |
Re: fstream objects are normally passed by reference, not by pointer. [icode]void delete_record( istream& file, string keyword ){[/icode]. This allows you to use [b]file[/b] just as if it had been declared inside the function and removed the indirection star. [icode]while ( *file >> fname && file->peek() != EOF )[/icode] It is … | |
Re: >>Do you have any solution for my problem? Yes -- compile for debug and use the compiler's debugger. Sorry, but that's about the best I advice I can give you without seeing the code and debugging it for you. | |
Re: I get this error with the link you posted [quote] [b]403 Forbidden![/b] The address you have entered is not open to the public, (This may be caused by not having a index.html file in your root directory). We advise you to visit our home page, as you could still find … | |
Re: Next time use code tags. line 36: where is year declared? line 46: why delete year immediately after entering its values? | |
Re: And next time [URL="http://www.daniweb.com/forums/forum38.html"]post in the right forum[/URL]. | |
Re: Don't limit yourself to just c++. Also take courses in C#, VB, Java. HTML, and other languages to broaden your skills. And toss in a course or two in databases, such as SQL language. The more you know the better your resume will look to potential employers. | |
Re: change_r() is pointless. All it does is return the same value that was passed in as the parameter. | |
Re: post some of the error messages. Function Search() -- Is [b]state[/b] supposed to be one of the 50 USA states? If yes, then it can not be an integer, but must be 2 character array followed by a null terminator (total of 3 characters). If not, then you need to … | |
Re: >>Include winuser.h That should not be necessary since he's already including windows.h >>Im using Visual Studio Professional edition. Which version -- there are several of them. >>but there are some errors rising while compiling it, the two most importants are : Are there other errors listed before the two you … | |
Re: If you are trying to learn c++ with Tubro C++ then forget it. That compiler is non-standard and too old to do anyone any good. Get a modern free compiler such as Code::Blocks or Microsoft VC++ 2008 Express if you want to learn c++ the modern way. And what you … | |
Re: cout does nothing in windows programs because they do not have a console window, nor do they have a main() function. [URL="http://www.codeguru.com/forum/archive/index.php/t-191786.html"]Here are some hints [/URL]how to draw text on windows canvas. | |
Re: Works for me [icode] MessageBox(0,"Hello\nWorld","MyProgram",MB_OK);[/icode] | |
Re: No. That feature does not exist in C or C++ languages. In C++ the nearest thing I can think of would be <map> that maps a name with a string (or other item). But that's not really the same because you can't use it like a variable. | |
Re: Open the file in binary mode, not text, then read each byte into an unsigned char, which has a value 0-255. If you want to count the number of occurrences all you need is an array of 255 and use the char as the index into the array [code] int … | |
Re: OMG what in the world are all those getline() calls???? If you want to put all those strings into the vector then use a loop! Use a string object to read the string and delete that damned character array (sztemp) which just takes up useless stack space. Replace lines 19 … | |
Re: >>[Linker error] undefined reference to `WinMain@16' You created the wrong kind of project -- create a new [b]console[/b] project then copy/paste that program into it. >>should I put that on line 25 of my code or right after mian ends? Exactly as shown. Read the [URL="http://alleg.sourceforge.net/"]allegro tutorials here[/URL] | |
Re: What functions are you using to do the copying? win32 api [URL="http://msdn.microsoft.com/en-us/library/aa363852(VS.85).aspx"]CopyFileEx()[/URL] will call your function for each portion of the file that has been copied, allowing it to update the progress bar. | |
Re: [QUOTE=hashinclude;366172]hello , first i want to say that im very new at c++ , i managed to create a very simple program through searching the internet , this little program involves running a certain exe file with parameters : (e.g: "c:\folder\file.exe" -parameter1 -parameter2) i am using the system() function to … | |
Re: I don't know a thing about it, but did you check [URL="http://www.google.com/search?hl=en&q=Web+Site+Scraping+software+"]google[/URL]? | |
Re: >>These headers will "load" other headers..? Is this illegal? Yes. Many standard system header files include other header files. >>in this case its not bad, but if im using some audio processing function, it could name-clash with a similar function for midi.) There will be no name clashes because that's … | |
Re: This works. But frankly I don't like using those win32 api file i/o functions because standard c++ std::fstream is a lot easier to work with. [code] #include <windows.h> using namespace std; int main() { HANDLE hFile = CreateFile("TextFile1.txt", GENERIC_READ|GENERIC_WRITE, 0,0,OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); if( hFile != INVALID_HANDLE_VALUE) { char text[] = … |
The End.