15,300 Posted Topics
Re: I have had the same question about how to disable UNICODE settings -- thanks WolfPack for the help. But even after that, I also get the unresolved external MessageBox error. Can't it be used in console applications?? I use it in console apps with VC++ 6.0 compiler without any problems. … | |
Re: start at the beginning, not somewhere in the middle of things.[URL=http://www.winprog.org/tutorial/]Here[/URL] is a good tutorial to get you started. | |
Re: one place a reference is needed and pointers will not work is overloading the [] operator. You couldn't implement this [b]as neatly[/b] using pointers. And the reference can be used on both left and right side of the operators, as illustrated in main() below. [code] #include <iostream> using namespace std; … | |
Re: you will probably want to truncate all trailing spaces first before using Narue's solution. Otherwise it will not work if the line is like this [code] "1 John US 1234.00 "[/code] | |
Re: here is one way to do it. It just has the string hard-coded, but you should be able to easily make it work with data file. Also assumes int is at the beginning of the string -- you should be able to change it to recognize int in the middle … | |
Re: when you press 'y' followed by <Enter> key, there are two keys in the keyboard buffer -- so the second time through the code it is probably getting the '\n' key. you need to flush the keyboard buffer to remove the '\n'. [code] scanf("%c", &yorn); getchar(); //flush the keyboard buffer … | |
Re: I don't know how you posted that code, but you should have use simple code tags. Please edit your post to use code tags. [ code ] // code goes here [ /code ] just remove the spaces between the square brackets. unless you are using a very very old … | |
Re: what errors does your compiler produce? post the first few error messages. | |
Re: does it work the way it is intended? If yes, then why fix something that ain't broken? But its obvous that it doesn't do what you want it to do. What kind of [b]database[/b] are you supposed to use? MySql, MS-Access, simple flat-text file? or something else? | |
Re: did you really write that program? or did you just copy it from somebody else? Look closely and you will see that it is printing the same thing over, and over and over one each iteration. But of course you already know that if you had written it youself :rolleyes: | |
Re: use braces to encose blocks of code. The below may or may not be what you intended. [code] for(int d=0; d<DEPTH; d++) { for(int r=0; r<ROW; r++) { array[d][r] = **this for(int c=0; c<COL; c++) { array[d][r][c] = cells.array[d][r][c]; } return *this; } } [/code] | |
Re: there is no such thing (keywords) as [b]function script[/b] in either c or c++. maybe in managed c++ (I don't know managed c++), but VC++ 6.0 compiler doesn't know how to compile managed code. | |
Re: erase the window -- get current window RECT object then call FillRect() with the desired color. | |
Re: return (x*(1 + (k*n)/(1 + (k*x)))); that is not inside any function. | |
Re: since this is a c++ program, use std::string instead of char arrays. std::string is a lot easier to use. [code] struct Node { std::string Descrip; double Price; int Quant; Node *Link; }; ... void InsertFunction(char *InitDescrip, double InitPrice, int InitQuant, Node *Current) { [color=red] Current->Descrip = InitDescrip; [/color] Current->Price = … | |
Re: different calling conentions are needed for mixed languge programs -- mixing C, Pascal, Basic etc in one program. | |
Re: [URL=http://www.boost.org/libs/numeric/interval/examples/newton-raphson.cpp]boost[/URL] may have one. search that link for the word intersect and see how it is used. | |
Re: since finalgrade class does not use any c++ std containers such as std::string you can write the entire class in one statement. put this in main() [code] ofstream out("file.dat", ios::binary); if( out.is_open()) { out.write(Students,sizeof(Students)); out.close(); } } [/code] and to read it back is just as simple [code] ifstream in("file.dat", … | |
Re: >>it is at the start or previous character is whitespace but i also need the or comma clause. just add more || operators on that line! [code] if( ch == temp || isspace (*(ch-1)) || *(ch-1) == ',') [/code] or you could use a switch statement [code] switch(*(ch-1)) { case … | |
Re: what doesn't "work promperly" ? compiler errors? runtime errors? if yes, post them. | |
Re: what do you mean "convert it over" ? from what to what? What problems are you having? you need a more detailed description of your problem(s) | |
Re: why do you think it is incorrect? Is the char count supposed to include spaces and periods? How about end-of-line terminating characters? Why not consider question mark ? and exclaimation point! as end-of-sentence terminators/ | |
Re: your program is littered with uninitialized pointers! set all pointers to 0 when declared and it will make your debugging a lot easier. Replace all those pointer arithmetic with normal array indexing. Make sure the program allocates memory before using it. [code] // replace this *(a+j)=new char*[w_len]; // exception attemtping … | |
Re: open the file, seek to end, the get current file position. How to do that depends on C or C++. There are also other ways, such as stat(), win32 api GetFileSize(), and others. | |
Re: is record.name a std::string object? If it is, I might be wrong but I don't think you can do binary reads and writes like you are doing with that string because all that is getting read/written is the number of bytes in the class itself -- the string is not … | |
Re: That identical set of questions has been posted before. google for the first question and you will find the answer(s). | |
Re: [QUOTE=niceguy21]how can i remove my username from this list if i want to[/QUOTE] pm Narue and I'm sure she will be happy to ban you if that is what you want. | |
Re: what compiler (and version) are you using? What is (are) the error messages? after including the C++ stl header files you need to declare the namespace [code] #include <iostream> ... other header files here using namespace std; [/code] | |
Re: data = &flag; that is incorrect. data is a pointer to a variable inside main(). If you want to change it, then you need to do something like this (typecast data to int pointer) *(int*)data = flag; That should fix the immediate problem, but then you need to add code … | |
Re: there are methods of sorting text files, but they are generally pretty complicated. If the file is small enough, just read all the strings into an in-memory array, sort the array, then rewrite them back to the file. If you are writing c++ program that is pretty easy -- read … | |
Re: write a function to test the string to see if it contains only numeric digits. Fucntion should return true if the string contains only numeric digits or false otherwise. | |
| |
Re: are the argv[] strings in read-only memory? Maybe you need to copy the string to a temp buffer and use strtok on that temp buffer. | |
Re: you can't. Like the book says, derived class inherits ALL members of the base class. But, what you can do is make members of the base class not accessible to members of derived class by making base class members private. In the code below, class derived cannot access variable x … | |
Re: >>f it was, Narue, can you explain the reason atoi() is bad There is very little "bad" about atoi() -- you were using it incorrectly. It does have one problem in that it does not detect integer overflow. If you are going to use a function and don't really understand … | |
Re: 1. where is [b]menuItemList[/b] object declared? 2. why all those useless lines that access the structure but does nothing with them? For example: menuItemList.BaconandEggs; If it is supposed to be setting them to 0 -- it doesn't. | |
Re: If you are running Norton Antivirus turn it off during development. Sometimes it causes problems like that. Don't forget to turn it back on when you are done. | |
Re: set a boolean flag to indicate if the word is found in one of the two files. If not set then it must be a noun. Something like this sudo-code. Note: search second file ONLY if the word is not in the first file. [code] set flag to false search … | |
Re: The clues in the question are [b]modify data[/b] and [b]++ptr[/b]. Both these need non-constants. So the only possible answer is a). | |
Re: [code] std::string isbn; getline(fin,isgm); [/code] if you want to read them all into an array [code] std::vector<std::string> isbn_list; std::string isbn; while( fin >> isbn) isbn_list.push_back(isbn); [/code] | |
Re: 1. please use code tags when posting a lot of code. 2. you forgot to ask a question. Or did you just want us to see your gorgeous code? | |
Re: when you enter the filename from the keyboard do not use double backslash -- double slashes are only needed for string literals in your program. So you should type [b]c:\fred.txt [/b], only one backslash. Reason: the compiler does not interpret anything you enter from the keyboard, it only interprets string … | |
Re: what compiler are you using? I just tried it with VC++ 2005 Express and had no problems. | |
Re: [code] #include <string> #include <iostream> #include <algorithm> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { string myString ("abcd"); [color=red] transform(myString.begin(),myString.end(),myString.begin(),toupper);[/color] cout << myString << endl; cin.ignore(); return 0; } [/code] | |
Re: You can use the printer's device driver and win32 API [URL=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/prntspol_9qnm.asp]OpenPrinter[/URL] and associated functions. (Scroll down to the bottom of the page and you will find other links). | |
Re: 1. put all the numbers in an array and short it. 2. create a 2d array, the first dimension contains the number and the second dimension contains a count of the number of times the number appears. The program will have to iterate through the original array (#1 above) and … | |
Re: [quote]Can someone tell me if its correct?[/quote] why do you need someone to tell you that? You can do it yourself just by running the program. Does it do what it is supposed to do? Yes, then it is correct. No, then you need to rewrite parts of it. | |
Re: you can allocate a class just like you did for that array [code] class MyClass { // blabla }; int n = 5; // allocate an array of class objects MyClass* pClass = new MyClass[n]; // // allocate only one class object MyClass* pClass = new MyClass; [/code] | |
The End.