15,300 Posted Topics
Re: >>Is the parameter like a refrence to another function Yes -- it is a pointer to another function. The function can be either a normal global function or a static method of a class and must take parameters as prototyped in that line. example: [code] void foo(Type** resource, char*name, char*path) … | |
Re: getcwd() will return the full path to the current folder. Or ".\\myfile.txt" or "./myfile.txt" | |
Re: That's one of the best commercials I've seen in a long long time :) But I live in Budweiser country. | |
Re: line 49: for your own sanity and the benefit of others who must read and understand your program put those } braces on separate lines and in line with the opening {. Don't be afraid to make liberal use of white space in your code. | |
Re: >>what can i do with c++???? You can use vector instead of arrays. line 5: should be <string> to get std::string class line 24: use [b]int main()[/b] line 129: you need to make that function return a value if the loop never finds what it is looking for. Spell out … | |
Re: line 11: you don't do it like that. use single quotes to compare characters [icode]if (str[x] == 'a') [/icode] [edit]^^^ like he said[/edit] | |
Re: I don't know the answer to your question but there's got to be a much simplier way to code that switch statement. What are you going to do if someone wants to be a level 255? Lets see -- 20 lines of code for level 2 I guess will mean … | |
Re: read [URL="http://www.google.com/search?hl=en&q=c%2B%2B+sort+algorithms&btnG=Search"]these google links[/URL]. | |
Re: >>Can anyone help me that how to develop the codes. Sure thing -- start here [code] #include <stdio.h> int main() { // put your code here } [/code] | |
Re: fgets() appends the '\n' to the end of the string, so you have to truncate it before you can use fname to open the file [code] fgets(fname ...); if( fname[strlen(fname)-1] == '\n') fname[strlen(fname)-1] = 0; [/code] line 36: The answer to your question can be done a couple ways. I … | |
Re: Do you remember the TV miniseries [b]V[/b] ? That's my idea of what aliens would be like. They come to Earth to harvest its human population for food. | |
Re: what part(s) of that do you know how to write? Break the problem down into smaller parts and it will be a lot easier for you to write. For example: to start off "Write a c++ program". To that much first by just writing the shell of main(). "reads from … | |
Re: you will have to do that in several lines. [URL="http://opengroup.org/onlinepubs/007908775/xsh/popen.html"]popen()[/URL] [URL="http://www.opengroup.org/onlinepubs/009695399/functions/getcwd.html"]getcwd()[/URL] [code] #include <stdio.h> int main() { char path[255] = {0}; char command[320] = {0}; strcpy(path, getcwd()); strcpy(command, "explorer.exe "); strcat(command, path); FILE* fp = popen( command, "r" ); // now read from the file pointer just as you would … | |
Re: Maybe that car was almost out of gas and he was rushing to the next gas station that's about 100 miles away :) | |
Re: that is a template and works with strings as well as integers. [code]int main() { string a = "Hello"; string b = "World"; swap(a,b); cout << a << " " << b << "\n"; return 0; } [/code] | |
Re: Welcome to DaniWeb. When you think you have most of it done post a link to it in Website Reviews and people will make comments. | |
Re: you need to pass [b]numElements[/b] by reference in addMessage() function just like you did in load(). | |
Re: are the user names and passwords in two different files ??? Normally they would be in the same file and on the same line. such as [icode]troula mypassword[/icode] | |
Re: when posting that much code you need to post all of it so that it will compile cleanly (unless that's the problem). main.cpp does not contain the include files and class Medicane is undefined. | |
Re: you don't need to use the Replace method -- just simply index into the array [code] int i = 0; int len = m_VideoName.GetLength(); while( i < len ) { while(i < len && isspace( m_VideoName[i] ) && ispunct(m_VideoName[i])) ++i; if( i < len ) m_VideoName[i] = toupper(m_VideoName[i]); } [/code] | |
Re: do you mean the difference between [icode]void foo(int *array)[/icode] and [icode]void foo(int array[]);[/icode] ?? The difference: nothing. They are identical, just two different ways of saying the same thing. | |
Re: Several ways [list] [*]save values to a file on program exit and read on program start [*]save values in the registry [*]save values in the program *.exe file [/list] All you really need to do is save the installation date in a hidden file somewhere then read it each time … | |
Re: Please post the first 3 or 4 lines of the input file. | |
Re: >> file.write((char*)&(*newVecService[i]), sizeof(*newVecService[i])); try this: [icode] file.write((char*)newVecService[i], sizeof(*newVecService[i]));[/icode] newVecService[i] is alread a pointer -- no need for all that typecasting. >>void saveFile(vector<Service*> newVecService) pass the vector by reference to avoid duplicating the vector [icode]void saveFile(vector<Service*>& newVecService)[/icode] >>Service *newServ; >>vector<Service*> vecService(300,newServ); You are initializing each of the 300 vector elements with … | |
Re: your are right and there is nothing you can do about it because of the way floats and doubles are stored in memory. wikipedia has a [URL="http://en.wikipedia.org/wiki/Floating_point"]good article about that[/URL] | |
Re: What compiler are you using that produces the error? There is nothing wrong with that header file. You don't need to typedef that struct in C++ because structs are almost identical to classes. So all you need is this: [code] struct VE {int maxnr; int n; int *a; }; [/code] | |
Re: line 44: you need to include <ctime> Otherwise this is what I get. Is it right or wrong? I'm not certain what your code is trying to do but from the looks of the output it looks like you are trying to sort the array [quote] Array before Partitioning(20) -> … | |
Re: Its hard to believe that any teacher would give that assignment in a Programming 101 type into class. You would probably have to write some sort of pattern recognition program, which is highly specialized and advanced type of programming. Not something that a newbe, or many oldtimers, could tackle. Sounds … | |
Re: >>Oh btw, can someone also explain what this is 'srand ( time(NULL) );'. I read that I have to use it for some reason but I'm not too sure srand() seeds the random number generator so that it will generate a different set of random numbers every time you run … | |
Re: >>Is that possible Yes it is, in fact its common for large programs to have hundreds of *.cpp files. >>How can I achieve that? The most common way is to create a header file and include it in each of the *.cpp files [code] // myfile.h header file extern void … | |
Re: You can't do this because too many parameters `ofstream& operator<<(ofstream& out, float *p, int arraySize)` But you can put that pointer into a structure and make the operator output the struct struct arr { float* p; int arraySize; }; ofstream& operator<<(ofstream& out, struct arr* p) { } | |
Re: fin.seekp(ios::begin) fin.clear(); >>Hope you have tried... SeekTobegin() That is only for MFC CFile class. Not available to anything else. | |
Re: You can write DLLs or shared libraries that extend the functionality of a program, but beyone that the answer to your question is NO because C and C++ are not interpreted languages. | |
Re: No special compiler needed. What you need is to use ODBC (there are other ways that are more specific to the database, but ODBC is common to them all) google [URL="http://www.google.com/search?hl=en&q=ODBC+c%2B%2B+classes"]ODBC c++ classes[/URL] and you will find several free ones. I'd also suggest you read some [URL="http://www.google.com/search?hl=en&q=ODBC+tutorial"]ODBC tutorials[/URL] and [URL="http://www.google.com/search?hl=en&q=SQL+tutorial&btnG=Search"]SQL … | |
Re: >>while(!inFile.eof()) wrong way to code that loop [icode]while( getline(inFile, title) )[/icode] | |
Re: [b]private[/b] variables can only be accessed by the class . [code] class A { private: int x; public: void SetX(int n) { x = n; } // <<< this is ok }; int main() { A aobj; aobj.x = 0; // << error because not inside the class } [/code] … | |
Re: >>sent[num]; what you should do here us use strcpy() to copy the first random string into sent variable, then strcat() to copy each of the other strings. >>printf("\n\n%s %s %s %s %s %s.\n\n", a[i], n[i], v[i], p[i], a2[i], n2[i]); variable i is not a random number. you should use variable … | |
Re: So what have you done for the past two weeks other than stare at the requiremeents in disbelief ? Have you actually attempted to write those two classes ? Have you studied your textbook and listened to your teacher's lectures? I know that every textbook ever written about c++ will … | |
Re: [QUOTE=Carwy;573618]Well lets see this is my second semester of school. How long did you have to become an ass?[/QUOTE] If you cant' take the heat then get out of the kitchen. Second semester student is very good, but after you graduate and get your first job you will only begin … | |
Re: Another suggestion is replace the character array with std::string and you can keep those == comparison operators because std::string permits them. | |
Re: This is no such concept as multi-line strings. If you want CR/LF in the string then just append "\n" whereever you want a new line to begin when output [code] std::string hello = "Hello\nWorld\n"; cout << hello; [/code] | |
Re: classes/structs must be terminated with a semicolon, which is missing at the end of hourlyEmployee_h | |
Re: You have to find out where [b]frm1[/b] is declared. Is it a member of a class in which the code snippet you posted resides? Look in the *.h files and see where that variable is declared. Or is it even in a header file. | |
Re: >> whoever is hanging on to that crap is not likely to shell out much cash for new program >>development on what is probably a maintenance money sink as it is I know of several manufacturing companies that are still using it on the assembly lines. Why? Because it is … | |
Re: >>Is the only around this to use arrays? Or linked lists -- yes. I would think something like below will work. You will probably want to declare the pointer in the class header file instead of the *.cpp file as shown below so that it doesn't disappear when the function … | |
Re: I think you are asking when you add a string to the combo box the currently selected string becomes unselected causing ItemIndex to be invalidated ? If that is true then you will want to save the currently selected string in a local variable in your function, add the string, … | |
Re: >>i did not want to ressurect old threads. Good -- you might have teen tounglashed had you done that :) Write a function that keeps track of all the random numbers it creates. Put the numbers into an array then each time a number is generated search the array to … |
The End.