15,300 Posted Topics
Re: system() function takes a lot of time to execute. There are better ways to do that which do not use cmd.com (or command.com). [code] c++ -- cin.ignore() will wait for user input or cin.get() c -- getchar() [/code] | |
Re: [QUOTE=Savage221]ok, thanks. The only part that worries me is the teacher is pretty strict on the code format, if we use different methods than what he wants he will make us change it. The teacher has made errors before in the instructions but it says the array needs to be … | |
Re: that may be fun to write, and you will most likely learn a great deal from it, but you should learn to use standard c++ or C functions, afterall that's why they are standard. For example, here is how to convert an int into string with no effort [code] #include … | |
Re: [QUOTE=vicky_dev]The change in printf() doesn't really make a difference. The memory allocated is always the same. It does concern the OS, but how can the same memory location be allocated to two variables at the same time?[/QUOTE] Not certain, but the address you see is probably the offset from the … | |
Re: [QUOTE=Asif_NSU]If you still want to stick to calloc, malloc etc. then try farmalloc or halloc i.e. you may have to change the memory model.[/QUOTE] Those two functions are only available on ancient 16-bit compilers such as Turbo C. Modern 32-bit compilers have no such functions. OP didn't say what compiler … | |
Re: nothing in MS-Windows programming is "simple". If you want "simple" then stay with console programs. The function FillListBox() that was previously posted looks simple to me -- only 3 program lines. The rest of that post is common code that is required by all MS-Windows program using win32 api functions. | |
Re: using the >> operator, cin will split up the text for you. In the code you posted, if you display the value of details variable you will see that it only contains the first "word". If you typed "John 19 10 06 1986", details will contain only "John". you will … | |
Re: learn to use your compiler's debugger and single-step through the code so that you can see what is going on. It's better than just guessing. | |
This is a simple example of how to use recursion to get a list of all the directories (folders) and file names within them. It also illustrates simple use if std::list, std::vector, std::string, std::cin and std::cout. It was compiled and tested with both VC++ 6.0 and Dev-C++ compilers on XP … | |
Re: See this [URL=http://www.winprog.org/tutorial/]tutorial[/URL] | |
Re: depends on the operating system. QT is portable between both *nix and MS-Windows. The others are not portable. I'm not a *nix programmer, so I can only say that on MS-Windows the Visual Studio .NET 2003 (2005 coming out this month) are the best. But again, it is not portable … | |
Re: what function(s) did the compiler say was missing? Look at your code and see if you coded them. If they are in a library somewhare did you include the library? | |
Re: your code is missing parentheses. Without parentheses, only the first line after the if statement belongs to the condition, all other lines will be executed regardless of the if condition. [code] if(flag == 1) [color=red]{[/color] printf("*********************************************************************\n"); printf("******************* item found ********************\n"); printf("*********************************************************************\n"); [color=red]}[/color] [/code] | |
Re: Can individual users, such as color blind people, customize the colors? They may not be able to easily read text that is in green, such as inside code tags. | |
Re: [code] tmp[r][c] == 0;[/code] The above is probably wrong. My compiler, VC++ 6.0, produced a warning -- your should have too. | |
Re: Its been my experience that .dat files contain binary data, such as the computer's binary representation of an integer and not the ascii digits that you will find in a text file. .dat files normally can not be easily read by text editors such as Notepad.exe. Exemple: [code] struct mystruct … | |
Re: If you want the clock in the display to tick off the time while you are typing in another control (such as an edit control), then use SetTime() to set an event to happen once a second. Then in that timer event update the clock display with current time. See … | |
Re: for CString (I assume you mean Microsoft MFC CString class) [code] // convert from CString to int just requires typcasting the CString CString str = "123"; int n = atoi((LPCTSTR)str); // convert from int to CString str.Format("%d", n); [/code] | |
Re: The two loops are not correct. Outer-most loop runs from 0 to (start-1). Inner-most loop runs from (outer_loop_counter+1) to start. There are other ways to do it, but I find this algorithm the most logical (easiest to comprehend) because neither loop counts backwards. [code] void sortAssending(int nums[], int size) { … | |
Re: [QUOTE=iamthwee][COLOR=Black]C[/COLOR][COLOR=Black]o[/COLOR][COLOR=Green]m[/COLOR][COLOR=Green]p[/COLOR][COLOR=Red]u[/COLOR][COLOR=Purple]t[/COLOR][COLOR=DarkOrange]e[/COLOR][COLOR=Black]r[/COLOR] [COLOR=DarkOrange]s[/COLOR][COLOR=DarkOrange]o[/COLOR][COLOR=Blue]f[/COLOR][COLOR=Black]t[/COLOR][COLOR=Black]w[/COLOR][COLOR=DarkOrange]a[/COLOR][COLOR=DarkOrange]r[/COLOR][COLOR=DarkOrange]e[/COLOR] [COLOR=Black]d[/COLOR][COLOR=Blue]e[/COLOR][COLOR=Blue]v[/COLOR][COLOR=Red]e[/COLOR][COLOR=DarkOrange]l[/COLOR][COLOR=Indigo]o[/COLOR][COLOR=DarkOrange]p[/COLOR][COLOR=Purple]e[/COLOR][COLOR=Indigo]d[/COLOR] [COLOR=Purple]f[/COLOR][COLOR=Purple]o[/COLOR][COLOR=Green]r[/COLOR] [COLOR=Purple]t[/COLOR][COLOR=Purple]h[/COLOR][COLOR=Purple]e[/COLOR] [COLOR=DarkOrange]p[/COLOR][COLOR=Black]u[/COLOR][COLOR=Purple]b[/COLOR][COLOR=Black]l[/COLOR][COLOR=Blue]i[/COLOR][COLOR=Indigo]c[/COLOR] [COLOR=Indigo]d[/COLOR][COLOR=Blue]o[/COLOR][COLOR=DarkOrange]m[/COLOR][COLOR=Blue]a[/COLOR][COLOR=Red]i[/COLOR][COLOR=Red]n[/COLOR][COLOR=Black],[/COLOR] [COLOR=Red]w[/COLOR][COLOR=Purple]h[/COLOR][COLOR=DarkOrange]i[/COLOR][COLOR=DarkOrange]c[/COLOR][COLOR=Green]h[/COLOR] [COLOR=Indigo]c[/COLOR][COLOR=DarkOrange]a[/COLOR][COLOR=DarkOrange]n[/COLOR] [COLOR=Black]b[/COLOR][COLOR=Indigo]e[/COLOR] [COLOR=DarkOrange]u[/COLOR][COLOR=Indigo]s[/COLOR][COLOR=Purple]e[/COLOR][COLOR=DarkOrange]d[/COLOR] [COLOR=Green]o[/COLOR][COLOR=Blue]r[/COLOR] [COLOR=Green]c[/COLOR][COLOR=DarkOrange]o[/COLOR][COLOR=DarkOrange]p[/COLOR][COLOR=Blue]i[/COLOR][COLOR=Indigo]e[/COLOR][COLOR=Indigo]d[/COLOR] [COLOR=Blue]w[/COLOR][COLOR=Indigo]i[/COLOR][COLOR=Purple]t[/COLOR][COLOR=DarkOrange]h[/COLOR][COLOR=Black]o[/COLOR][COLOR=Indigo]u[/COLOR][COLOR=Blue]t[/COLOR] [COLOR=DarkOrange]i[/COLOR][COLOR=Purple]n[/COLOR][COLOR=Black]f[/COLOR][COLOR=Blue]r[/COLOR][COLOR=Blue]i[/COLOR][COLOR=Red]n[/COLOR][COLOR=Red]g[/COLOR][COLOR=Indigo]i[/COLOR][COLOR=DarkOrange]n[/COLOR][COLOR=DarkOrange]g[/COLOR] [COLOR=Indigo]c[/COLOR][COLOR=Red]o[/COLOR][COLOR=Indigo]p[/COLOR][COLOR=DarkOrange]y[/COLOR][COLOR=Red]r[/COLOR][COLOR=Black]i[/COLOR][COLOR=Red]g[/COLOR][COLOR=Purple]h[/COLOR][COLOR=Black]t[/COLOR][COLOR=Green].[/COLOR] [COLOR=Green]P[/COLOR][COLOR=Black]r[/COLOR][COLOR=Indigo]o[/COLOR][COLOR=DarkOrange]g[/COLOR][COLOR=Black]r[/COLOR][COLOR=Blue]a[/COLOR][COLOR=Green]m[/COLOR][COLOR=Red]m[/COLOR][COLOR=DarkOrange]e[/COLOR][COLOR=Purple]r[/COLOR][COLOR=DarkOrange]s[/COLOR] [COLOR=Blue]t[/COLOR][COLOR=Indigo]y[/COLOR][COLOR=Purple]p[/COLOR][COLOR=DarkOrange]i[/COLOR][COLOR=Indigo]c[/COLOR][COLOR=Red]a[/COLOR][COLOR=Indigo]l[/COLOR][COLOR=Indigo]l[/COLOR][COLOR=Green]y[/COLOR] [COLOR=Blue]g[/COLOR][COLOR=DarkOrange]e[/COLOR][COLOR=Blue]t[/COLOR] [COLOR=Blue]p[/COLOR][COLOR=Red]a[/COLOR][COLOR=Red]i[/COLOR][COLOR=DarkOrange]d[/COLOR] [COLOR=Green]a[/COLOR] [COLOR=Indigo]s[/COLOR][COLOR=Blue]m[/COLOR][COLOR=DarkOrange]a[/COLOR][COLOR=Black]l[/COLOR][COLOR=Red]l[/COLOR] [COLOR=Black]o[/COLOR][COLOR=Black]n[/COLOR][COLOR=DarkOrange]e[/COLOR] [COLOR=Green]t[/COLOR][COLOR=Green]i[/COLOR][COLOR=Indigo]m[/COLOR][COLOR=Indigo]e[/COLOR] [COLOR=Indigo]f[/COLOR][COLOR=Blue]e[/COLOR][COLOR=DarkOrange]e[/COLOR] [COLOR=Green]f[/COLOR][COLOR=Red]r[/COLOR][COLOR=DarkOrange]o[/COLOR][COLOR=Purple]m[/COLOR] [COLOR=Red]u[/COLOR][COLOR=Red]s[/COLOR][COLOR=Indigo]e[/COLOR][COLOR=Purple]r[/COLOR][COLOR=Black]s[/COLOR] [COLOR=Red]w[/COLOR][COLOR=Indigo]h[/COLOR][COLOR=Red]o[/COLOR] [COLOR=Red]f[/COLOR][COLOR=Black]i[/COLOR][COLOR=Red]n[/COLOR][COLOR=Blue]d[/COLOR] [COLOR=DarkOrange]t[/COLOR][COLOR=Green]h[/COLOR][COLOR=Indigo]e[/COLOR] [COLOR=Black]s[/COLOR][COLOR=DarkOrange]o[/COLOR][COLOR=Purple]f[/COLOR][COLOR=Indigo]t[/COLOR][COLOR=Blue]w[/COLOR][COLOR=Blue]a[/COLOR][COLOR=DarkOrange]r[/COLOR][COLOR=Black]e[/COLOR] [COLOR=Blue]u[/COLOR][COLOR=Green]s[/COLOR][COLOR=Red]e[/COLOR][COLOR=Indigo]f[/COLOR][COLOR=DarkOrange]u[/COLOR][COLOR=Red]l[/COLOR][COLOR=Indigo].[/COLOR][/QUOTE] you worked very very hard to make that post with so many different colors :mrgreen: Is there an … | |
Re: [quote]sprintf("Got Data: %s\n", buffer);[/quote] The above is wrong. Was it just a posting error or is it really like that in your program ? [quote]sprintf([color=red]InputBuffer,[/color] "Got Data: %s\n", buffer);[/quote] or [code] strcpy(InputBuffer,"Got Data: "); strcat(InputBuffer,buffer); [/code] | |
Re: [QUOTE=bigwillis234]Now the thing works but it takes about 6 hrs to run[/QUOTE] LMAO :lol: :lol: :lol: Sorry for laughing so much! But the last time I heard something like that was way back in 1987 on an old Unix computer -- the program (no, I didn't write it) took 48 … | |
Re: set a timer event for the amount of time you want it displayed, then in the event handler kill the message box -- send it WM_CLOSE event. | |
Re: dbd should be year-1, not year-1850. for the days in current year, you need to use a table that will contain the cumulative number of days from 1 Jan to the end of the previous month. Using a table for this saves a lot of time because loops are expensive. … | |
Re: I think you will want to search [URL=https://www.bluetooth.org/]here[/URL] and ask that question on one of its public forums. | |
Re: [QUOTE=some one]hi plzzz i need ahelp to know what rong with this program the problem is in the display function the code[/QUOTE] what do you think is wrong with it? Do you get compiler errors? If yes, what errors? Or are there runtime errors -- what are they. Function display() … | |
Re: the code you posted should not even compile because class A is missing the overloaded = operator. in main(), the line "a = 1" does NOT call the default constructor as you might think, but will call the = operator. And since you did not define one the compiler should … | |
Re: make the variables global and don't pass any parameters. An alternative (and better) is to make a c++ class to hold data and associated methods. [edit]Note: I did not run your program. Only made it compile without errors. :rolleyes: [/edit] [code] #include <iostream> using namespace std; void DisplayMenu(void); void Enter_Inventory(); … | |
Re: google for ODBC -- there's lots of information about it, and some c++ classes too. You could also use ADO or DAO, but I don't know much about them. ODBC is the oldest of the three and is supported by nearly all commercial database engines. | |
Re: This is a c++ program -- why are you wrinting your own linked lists instead of using STL <list> classes? | |
Re: also, the numbers are all too big for any 32-bit compiler. | |
Re: This will work -- the function must return char* which is a pointer just like the parameter. But there is no point passing the parameter if the function is going to change and return the pointer. [code] char* outin(char *string,bool *bl) { if (bl==1){ string = "in"; } else if … | |
Re: [QUOTE=fiza]thnks jenny for your questions, and for those who posted the solution, thank you very much, u help me a lot :))[/QUOTE] you forgot to use the [sarcastic] and [/sarcastic] tags :cheesy: | |
Re: [QUOTE=server_crash]I'm trying to pass arguments to my program so that I can store them into an array. For some reason my IDE/compiler is treating the blank space in between arguments as an argument. [/QUOTE] There is nothing wrong with your compiler or IDE -- that is the customary way C … | |
Re: [QUOTE=Quan Chi2]I just need atleast a hint?[/QUOTE] start here [code] #include <iostring> using std::cout; int main() { cout << "What type of math problem will you be doing?: "; // put your code here return 0; } [/code] | |
Re: The easiest way is to input both as strings, not integers, then simply iterator through the string. Attempting to use integers makes that a lot more difficult. | |
Re: The only reason I know for returning the reference is when overloading operator[] so that it can be changed by the calling function. I suppose if the object being returned is large enough one could return a reference (or pointer) instead of a copy just to save processing time. In … | |
Re: you didn't say what the problem is. But I see a few problems in the Month class. Whenever the month number changes the month name must also change, and whenever the month name changes the month number must also change. I suggest moving those two large switch statements in the … | |
Re: ansiString is Borland's C++ builder string class. you can use its SubString method to remove the space. I don't use that compiler, but googled a bit and found this in about 5 seconds. [url]http://www.codepedia.com/1/CppBuilderGetExtension[/url] | |
Re: There are lots of c++ classes on the net. Some are at [url]www.codeproject.com[/url], just use its search engine to search for odbc, or google for "odbc c++ classes" | |
Re: [QUOTE=CrazyDieter] Forcing the value of a pointer is a bit dirty [/QUOTE] md: In MS-Windows and *nix it will most probably crash the program because the operating systems do not allow programs to access memory addresses that way. Gone are the days of MS-DOS when a program could just write … | |
Re: if p were an array, then the initializer list would have to be in braces, not parentheses, like this [code] int p[] = {1,2,2,100}; [/code] But the above is entirely different than the code you originally posted. | |
Re: I've read your question 3 times and the program once, but I still fail to understand the question. Yellow ? Where do you see the output colored in yellow? Must be your monitor doing that. | |
Re: read your textbook about scanf() -- what does it return? It certainly does not return price, as indicated by your code. Your use of scanf() return value is wrong. | |
Re: you mean you want someone to "do" your homework for you, not to "help" you do it. You don't (won't) learn a thing that way. Give it your best shot, read your textbook, practice, then post code and questions that give you problems. You get it all free right here. | |
Re: all file i/o functions on MS-DOS computers eventually call the win32 api functions such as ReadFile(), WriteFile(), CreateFile() etc. | |
Re: it will compile, but dereferencing a null pointer like that will often (but maybe not always) crash the program -- it's undefined behavior. In the case of c++ classes, the function will be called with an invalid "this" pointer and any attempt to reference or use class objects will also … | |
Re: post the contents of the data file, or just a few lines if its too large. Your program is written to expect all student ids to be listed first, followed by all answers and lastly the total number correct for each student. But I doubt that is how they appear … | |
Re: mixing c and c++ file operations is undesirable, but not something that will crash the program. Probably the reason it crashed is that there is no check to see if the file was opened successfully. You can't just assume that. The second reason is that c is defined as char, … | |
The End.