15,300 Posted Topics
Re: >>Please help the new programmer Well, if you are really new then you need to start at the beginning, not with some really difficult program. Read the [b]Read Me[/b] threads at the top of this board and you will get lots of help and places to look. | |
Re: First, make sure the destination string is NOT a string literal, and that the size of the destingation string buffer is large enough to hold both strings. Once you know that, then find the end of the destination string and copy the source string at that spot one character at … | |
Re: >>a sample program of c++ that uses a database There are several alternative ways to do it, all somewhat complex and require a confortable knowledge of C or C++ language.. The most common approach is ODBC, and you can find a few free c++ ODBC classes -- just do a … | |
Re: [quote]Write a program segment with a [b]do-while loop[/b] [/quote] your program does not do that. You used a [b]while[/b] loop, not a [b]do-while[/b] loop. Otherwise the rest of your program looks ok. | |
Re: pretty simple actually -- replace [b]cout[/b] with an ofstream object. You have already included all the necessary header files so all you have to do is declare an ofstream object at the beginning of the program and use it instead of cout wherever you need to. | |
Re: [b]chooseNumber()[/b] only permits the player to enter a value between 1 and 9. Yet the matrix is 15x12. Why the difference ? 1 and 9 are the values in the cells, not the matrix size. | |
Re: like [URL="http://www.daniweb.com/code/snippet87.html"]this ?[/URL] | |
Re: read the [b]INSTALL[/b] file and it will tell you that they used VC++ 6 and NASM assembler. [quote] 2.a/ Requirements. ------------------ - MS VisualDev 6 Processor Pack 5 or MS VisualDev 7 - nasm installed as 'nasm' in the msvc binary search paths. [/quote] | |
Re: >> am a newbie to the C++ arena attempting to write a windows program is NOT a good way to learn c++ language because it is too advanced. Start with something a lot simpler and work your way up from there. | |
Re: depends on how variable [b]crap[/b] was defined. If its a character array [inlinecode]char crap[255];[/inlinecode] then you are right. But if its a std::string then jamthwee is right. And jamthwee shows the prefered c++ method. | |
Re: If a guy marries his granny does that make him his own grandpa? Actually I think such a marriage would be legal in USA because the woman is probably beyone the child bearing age. | |
Re: The problem is in Read_File, you have to pass listTop pointer by reference so that Read_File() can change the value of the pointer that was created in main(). [code] void Read_File(resident *[color=red]&[/color] listTop, int &residentCount) [/code] Next problem with that function -- delete the declaration of [b]listTop[/b] at line 47 … | |
Re: you wrote it wrong -- what you wrote is the c++ class object, not the string contents. If the file is a normal text file where '\n' is line terminator then you need to tack on the '\n' to the end of the string then write only the string to … | |
Re: Here is one way to do it -- first read the entire line into a std::string object then parse it [code] int _tmain(int argc, _TCHAR* argv[]) { vector<string> sList; vector<float> fList; string name; float f; string line = "X = {1.0, 2.0, 3.0}"; // extract the name which size_t pos … | |
| |
Re: Yes I agree it is pretty good, and I don't normally like anything written before about 1950 :) | |
Re: you probably didn't initialize [b]totalNumber[/b] when declaring it [code] int totalNumber = 0; [/code] | |
Re: consider moving lines 10 thru 12 to the top of the program, above line 1. Traditionally include files go at the top of the programs and everything else follows. Sometime its a lot more than just [b]tradition[/b] but a requirement :). Without knowing more about what your program is supposed … | |
Re: I don't really know, but did you try the obvious ? [code] for(i = 0; i < 4; ++i) { for(j = 0; j < 4; ++j) { data[i][j] = gsl_matrix_column(i, j); } } [/code] | |
Re: you have mismatched braces in function checkPrime() that is causing the problem | |
Re: If you are unmarried and/or have no children to support then you don't need credit cards. But if you live in USA you will eventually join in the Great American Dream and get up to your eyeballs in debt. Almost nobody lives in this country debt-free and credit-card-free. | |
I'm glad to see that you added the "Toggle Plain Text" to normal code tags (those without a language specified). Thanks for making that change :) ![]() | |
Re: dont't declare it with [b]const[/b] keyword. A class object declared like that is pretty useless. | |
Re: Depends on what operating system you want to use. If MS-DOS version 6.X or earlier then you need to make it a TSR. There is quite a bit about that on the net, just google for it. MS-Windows doesn't use memory resident programs like that. It uses DLLs and device … | |
Re: >>but using the random number generators rand(), which I understand is not a very good idea why not ? >>but I have NO idea how define it in my class declare it as [b]static[/b] and there will only be one instance of it for all instances of your class. | |
Re: you need to repost your program because your original code will not produce that output. | |
Re: If you want to store mixed data than I'd use a structure that has two members: (1) a union between all the data types you want it to support, and (2) an int that indicates what kind of data is stored, such as 0 no valid data, 1 is an … | |
Re: Here is an example of one way to construct those filenames [code] #include <iostream> #include <string> #include <sstream> using namespace std; int main() { string st1 = "file"; string ext = ".txt"; string filename; for(int i = 1; i < 10; i++) { stringstream ss; ss << i; filename = … | |
Re: [QUOTE=toolmanx;453051]I didn't want to fill up a thread with a bunch of code, but I couldn't find a way to attach a file to an e-mail using this site's "send a message" system. I would have inserted the .CPP file. [/quote] Hit the [b]Go Advanced[/b] button then scroll down the … | |
Re: My GUESS is yes -- here is an [URL="http://www.codeproject.com/combobox/CustomListBox_Article.asp"]example tutorial[/URL] | |
Re: I just downloaded the source and compiled with VC++ 2005 Express with no problems using the project that was supplied with the source code. Is it the GLUT source code that you compiled or some file that you wrote? >>I had to install the *.h, *.o, and *.dll files by … | |
Re: just remove the "%s" -- its not necessary because [b]adress[/b] is already a string that contains the filename [code] file=fopen(adress,"a+"); [/code] | |
Re: For database support you can use [URL="http://www.google.com/search?hl=en&q=adoce"]ADOCE[/URL] from C and C++ programs. The DLL is installed with eVB compiler. It gets the data from a server computer and stores it on the wireless device that it is running on. As you are finding out (or have already found out) the … | |
Re: >>Enter Your Height In Feet And Inches: 5 4 use two variables, not one, something like this [code] int feet,inches cin >> feet >> inches; [/code] | |
Re: line 21 is a syntax error that your compiler should have complained about. Maybe its just a posting error ? After using scanf() to get an integer, scanf() leaves the '\n' in the keyboard buffer so the next time you call scanf it will appear as if it is not … | |
Re: A couple ways to solve your problem: 1. after opening the file call [inlinecode]seekp(ios::end); [/inlinecode]set the file pointer to end-of-file before writing 2. Add the ios::ate flag to the open statement: [inlinecode]fout.open("library.txt", ios::out | ios::ate);[/inlinecode] | |
Re: when you open the output file add the ios::ate flag so that the open function will move the file pointer to the end of the exting file data after it opens the file. Normally the file pointer is set to the beginning of the file and if you don't use … | |
Re: The open function does not take std::string object but a char*, so call its c_str() to get it [code] inFile.open(RES_FILENAME.c_str()); [/code] [edit]what Dave said ^^^^[/edit] | |
Re: Oh I see you are back [URL="http://www.daniweb.com/forums/thread93200.html"]to your old code again[/URL] ? >>fehler what is that? Please write in English on these boards. | |
Re: >>i can't call any function in the main (don't know how) almost identical to calling any normal function except you have to reference the name of the object. For example if you want to call [b]search_By_Id()[/b] then do it like this [code] obj.search_By_Id(); [/code] [b]setName()[/b] is wrong. since [b]Name[/b] has … | |
Re: Unbelievable. 75 posts and you still don't know how to format your code ! I certainly hope you do not plan to turn in that to your instructor. | |
Re: they are indeed different because one is an array and the other is not -- their size has nothing to do with it. | |
Re: [b]getchar[/b] uses round parentheses not square brackets to hold the parameters. you don't need the [b]&[/b] address operator on line 26 because arrays are ALWAYS passed by address. line 28 has a couple problems: if you only want one character then use "%c" instead of "%s". and it has the … | |
Re: depends on the operating system. [URL="http://msdn2.microsoft.com/en-us/library/ms724381.aspx"]Here is some info[/URL] for MS-Windows. You'll have to do some more reasearch to find other information. And why use assembly if you don't have to? A lot easier in other languages such as C or C++. | |
Re: [QUOTE=anirudhbsg;452347]that this lib file is there along with other file in the path that i have specified in directories path option[/QUOTE] If you mean the PATH environment variable then that is incorrect. The compilers I have used from the command-line all use the [b]-L[/b] option to specify path to libraries … | |
Re: >>the teacher said it should only contain one lineof code. [code] int flip() { return rand() % 2; } [/code] | |
Re: instead of getline() you could use the >> extract operator [code] string name; int number; int line_count = 0; while( myfile >> name >> number && line_count < x) { ++line_count } [/code] | |
Re: line 29 is wrong [code] while( fgets (buffer , 20 , pFile) ) { // blabla } [/code] fgets() normally adds the '\n' that is in the file at the end of the input string that you need to strip off. And it would make your life a lot easier … | |
Re: If you want to keep all existing values in the array then you need use a loop to shift everything down from the spot you want to add the new value. [edit]^^^ what Narue said [/edit] | |
We've all heard about people having guts or balls. But do you really know the difference between them? In an effort to keep you informed, the definition for each is listed below... GUTS - is arriving home late after a night out with the guys, being met by your wife … |
The End.