15,300 Posted Topics
Re: >>Can anyone help please? Thx! Sure can. See below [code] int main() { // put your code here } [/code] | |
Re: >>The language used in the book is so difficult tat i cud'nt understand tat.. Sounds like you are not yet quite read to study pointers. Yes, pointers can get very very messy and complicated very quickly. My suggestion for you is to stick the the simple pointers -- those with … | |
Re: First you have to create another menu item, and then write a function that implements it. Just a simple linear search will do -- from the first to last items in the array. | |
Re: I don't know what the problem is, but I see two glaring problems. [list=1] [*]scanf("%s", username); -- what happens if someone enters 20 characters as the user name? A: Program will most likely crash because username can only hold 8 characters. Solution: use fgets() instead of scanf() because fgets() will … | |
Re: you could just use '\r' to make the cursor return back to the beginning of the line [code] int cookTime(int time) { int second, minute; for (minute = time; minute > -1; minute--) { for (second = 59; second > -1; second--) { sleep(1); printf ("\r%2i : %2i", minute, second); … | |
Re: you can't use > or < in switch cases -- switch can only be used with constants. In the case you posted the if statements are the best way to handle it. I suppose you could write a switch statement with 100 cases, but that would be dumb. | |
Re: How to get all the files in a directory depends on the operating system. In MS-Windows use FindFirstFile() and FindNextFile() found in windows.h. If *nix use OpenDir() and ReadDir(). Then of course you may have to contend with subdirectories. The easiest way to do that is with recursion. Use strcat() … | |
Re: You need to use double pointer there so that foo() can allocate memory for the pointer in main(). You can do the same with as many other pointers as you like, it is not limited to just one pointer. This solves the problem is returning more than one string at … | |
Re: Are you trying to use a one dimensional array of integers to represent a two dimensional array? If yes, then matrix A would be represented as 1 2 3 4 5 6, and adding matrix B would make it 1 2 3 4 5 6 7 8 9. To find … | |
Re: After [icode]cin >> choice;[/icode] you need to flush the keyboard buffer of the '\n' character (Enter key). Just add [icode]cin.ignore();[/icode] after those lines and it should work | |
Re: Way too complicated and with unnecessary code. Here is a greatly simplified way to do it. Using strtok() you could parse a string that has more than one kind of deliminator, such as '\n' and '\t' and ',' and the space, these are typical of CVS files (exported XLS files). … | |
Re: you can't realloc() an array what was not a pointer to begin with. you could declare userAnswers as a char***. I've already convered similar situation in another thread here, so I won't repeat it. Just follow the syntax in the other thread how to do it. See my last post … | |
Re: you might get better shuffling results if you use std::random_shuffle() found in <algorithm>. | |
Re: line 11: you should name that character array something else because [b]string[/b] is declared in the header file <string>. Since you used [icode]using namespace std;[/icode] there is now a name clash between std::string and the string you declared in your WCS class. Your class would be a lot simpler if … | |
Re: The main problem with that class is that the constructor with only one constructor does not initialize the value of both class member variables mdim_ and ndim_. | |
Re: Who the hell wants to read all that crap??? [URL="http://www.daniweb.com/code/snippet217404.html"]Passwords code snippet here[/URL] | |
Re: If you want to display those variables in main() then you will have to declare them in main() and pass them by value to input() [code] int main() { int temp, windspeed; inpuut( &temp, &windspeed); } void input(int* temp, int* windspeed) { *temp = 30; *windspeed = 20; } [/code] | |
Re: I just installed 64-bit Windows 7 Home Prem the other day. I wanted to upgrade from Vista Home Prem, but the upgrade failed for some reason. So I just did a clean install. I've tried both Ubuntu and Fedora 11, but neither will let me play videos on my DVD … | |
Re: Q1: use normal FILE* i/o operations. See functions in stdio.h. You should be able to find tutorials. Q2: see argc and argv arguments to main [icode] int main(int argc, char* argv[])[/icode] | |
Re: >>anyone knows how to use clearscreen with dev [icode]system("cls");[/icode] If you dont' want to use system() then [URL="http://support.microsoft.com/kb/99261"]here is how to do it[/URL] with win32 api functions. | |
Re: >>turbo c still is not opening with dos [b]dos[/b] just stands for [b]disk operating system[/b]. Almost all operating systems have a [b]dos[/b], so which one are you talking about? Turbo C will not work with MS-Windows 7, so if that is what you are running either forget turbo c or … | |
Re: >>I'm starting to code the main program but i got a lot of errors when i compiled the code Fix the errors one at a time, recompile after each fix to see what's really left. Compilers like to puke up 10-20 errors for the same line. Post the first two … | |
Re: So let me get this straight. You have no clue about how to write a c or c++ program yet you expect to write something as complicated as that?? put this project aside for awhile until you learn the c++ language. | |
Re: >>This code gives me the following error for the line where the typedef is: windows.h already defines TRUE and FALSE, which are #define's, not typedefs. I suppose you could undefine them before that typedef, but that could cause many other problems with win32 api functions. >>or can I only use … | |
Re: you can use sprintf() to format the string then write() to write that string to the file. line 18: if the file can not be opened the program needs to do two things, not one. [code] if( id < 0) { perror(...); return 1; // abort the program } [/code] | |
Re: >>I've been playing with the code to get the things I need but nothing is working. That's nice -- now post the code you tried because we are not clairvoyant. | |
Re: A real-life project: Write a computer program that reads data from a serial port that contains UPC product codes from an external scanner device. Use that UPC code as a key to look up product information in an SQL database (such as MS-Access, MS-SQL Server, Oracle, Sybase, etc) then display … | |
Re: line 26: The value of argc will not be less than 1. The first argument to the program is the name of the program itself (on most operating systems). line 27 and 28: What are you trying to do there? cout knows nothing about %d format string. You need to … | |
Re: or maybe [icode]rm *.o target*.*[/icode] [edit]:icon_eek: ^^^ That will also delete the source code![/edit] | |
Re: Do you know how to use the [b]new[/b] operator to allocate an array? If yes, then just allocate an array that is twice the size as the array argument, such as [icode]size * 2[/icode] You will need a function something like this: [code] int* expand(int nums[], int size) { } … | |
Re: aint array must be allocated with new operator. The way you tried to do it is not yet supported by most c++ compilers. [code] linesize = line.size(); int *aint = new int[linesize]; // The arrays satisfying the condition [/code] | |
Re: What I would do is define a macro for my compiler, then it it's not defined the compiler would be the one your teacher uses. For example if you are using vc++ 2008 then you could use the[URL="http://msdn.microsoft.com/en-us/library/b0084kay.aspx"] predefined macro _MSC_VER[/URL] which is the compiler version [code] #ifdefined (_MSC_VER) #include … | |
Re: Post the code you tried.You could probably use the same character array for all n number of strings because you didn't say there was a requirement to save all those strings. | |
Re: A couple ways to do it 1) create a structure that contains the keyword and count of the number of times it appears. Then create an array of those structures, one element for each keyword on the command line. Then read each word of the file, for each word loop … | |
Re: I don't understand what you are asking. That function will sum up however many integers you want to pass to it as long as the last parameter is 0 so that the function knows when to stop. You might want to recode that while loop because the first time through … | |
Re: system() is a c and c++ function. Otherwise you have to use os-specific functions such as the spawn family of functions on *nix, of ShellExecute() and CreateProcess() on MS-Windows. | |
Re: The variable name on line 3 is the same as the function name on line 1 -- bad idea. [URL="http://www.functionx.com/visualc/controls/checkbox.htm"]Read this article[/URL]. Your program has to call one of the checkboxes methods to find out whether it was checked or not. | |
Re: Step 1: call function time() to get current time in seconds. Step 2: call localtime() to convert the integer returned by Step 1 into a struct tm Step 3: Check if tm_mday is 1 | |
Re: Yup, your program was doing integer division, therefore 2/5 is 0 but 2.0/5 will give you the result you desire. | |
| |
| |
Re: Looks ok to me -- just remember that srand() is executed only once during the entire lifetime of the program while rand() is executed as many times as you need it. | |
Re: [QUOTE=Fbody;1132718] Your syntax isn't correct, but....[/QUOTE] I don't see anything wrong with the syntax he posted. [icode]int* q = a;[/icode] is perfectly valid as long as a is an array of integers. [edit]Oh, I think you meant [icode]int &p=a;[/icode], which is illegal. | |
Re: The static_cast<> lets the c++ compiler do a better job of ensuring the cast is valid. For example: this will produce a compiler error (vc++ 2008 express) [code] int main() { int x = 123; char* p = static_cast<char*>(&x); // << ERROR char* p = (char*)&x; // << NO ERROR … | |
Re: I suppose you could iterate through the map and sum up the length of all the strings and the number of bytes occupied by all those integers. Then there will be a small overhead the map class needs for each of the nodes. | |
Re: You are not going to find a tutorial that does all that stuff. Learn one thing at a time. google for "ODBC tutorials" and you will find out how to access SQL databases -- you need a good understanding of C or C++ languages. Once you learn that (maybe a … | |
Re: Are you compiling your program for UNICODE ? | |
Re: >>if (*(array i) == *(array i) && &*(array k) != &*(array You must have mis-quoted it because that makes no sense. |
The End.