15,300 Posted Topics
Re: use setw() to set the width of a column [icode]cout << setw(20) << name << setw(4) << pay // etc. etc[/icode] | |
Re: >> input[0] = toupper(input[0]); And what will happen if the first character is white space? [code] #include <iostream> #include <string> int main() { std::string line; while( std::getline(std::cin, line) ) { std::string::iterator it = line.begin(); for(; it != line.end() && isspace(*it); it++) ; *it = toupper(*it); std::cout << "\"" << line … | |
Re: Learning from online tutorials will only get you a small part of the way to your goals. You can start there, but eventually you will have to invest some $$$ (money) to buy a few good reference books. Ultimately if you want to make programming a career then you will … | |
Re: 1. never ever use gets() -- it can destroy your program at runtime if you enter more characters than the input buffer can hold. Use fgets() instead to limit input. The downside to that function is you have to remove the trailing '\n' charcter (the <Enter> key) 2. I assume … | |
Re: Use [noparse][code] ... [/code][/noparse] tags -- they will add line numbers for you so that you don't have to do it yourself. You said the function returns just a single character yet you are trying to return a character array. You can't have it both ways. What you should have … | |
Re: >>void print (first1); Just like arguments to any other function you have to tell it what kind of objectg first1 is -- such as [icode]void print (Gnode* first1);[/icode] | |
Re: Line 4: remove that semicolon at the end of the line. That is what is causing the error message. | |
Re: Procrastination?? You deserve to flunk that assignment. | |
Re: The c++ compiler/IDE in the article is no longer recommended -- Dev-C++ too old and obsolete. Either of the following free compilers/IDEs are now recommended [URL="http://www.codeblocks.org/downloads"]Code::Blocks with MinGW compile[/URL] [URL="http://www.microsoft.com/express/Downloads/"]VC++ 2010 Expess[/URL] [URL="http://www.winprog.org/tutorial/"]Here is a tutorial[/URL] for introduction into MS-Windows GUI programming using pure win32 api functions. | |
Re: "a" is a pointer to the letter 'a', it is not c++ class std::string. You can only use the + operator on std::string [code] std::string a = "a"; std::string b = "b"; std::string c = "c"; std::string text = a+b+c; [/code] | |
Re: >>As s thing that its better to not use any database just bec of the person who will gonna use it ,maybe he dont have install sql or something in his/her computer that way the use just file. You could use SqLite, which is completely embedded in your program and … | |
Re: Replace cout with printf() Replace cin with scanf() Replace ofstream and ifstream with FILE* Replace [icode]fin >> [/icode] with fread() or possibly fgets(), depending on what is being read. Replace [icode]fout << [/icode] with fwrite(), or possibly fprintf(), depending on what is being written. | |
Re: >>i have c compiler so can i use it or i need c++ compiler and where can i get it Depends on the C compiler you are using. Most modern compilers will compile both C and C++, depending on the file exten. *.c is normally compiled as C code while … | |
Re: getline() does not add the new line character to the end of the string, so if you display the string don't add endl or '\n' after it. | |
Re: A solution is actually even simpler than what David suggested above. But I think the OP's instructor wants him to use that c++ class he posted. He will have to use an array, or vector, of those class objects. IMO that's really a dumb way to solve the problem, but … | |
Re: [b]Turn it [color=red]ON[/color], stupid.[/b] | |
Re: >>I just need to find a computer somewhere that I know hasn't already had the vc++ redistributable installed on it already That should be quite easy -- just do a fresh install of the Windows operating system. | |
Re: An example of a fake signature is what the mods snipped from your post. It consists of one or more links. Click the CONTROL PANEL link found at the top of evey DaniWeb page. On the left side of that page you will see a list of links, one of … | |
Re: Here is an example of how to copy all the subfolders and files to a new destination folder. Looks like you are using managed code, so I don't know how to use unmanaged win32 functions in managed programs. [code=cplusplus] #include <windows.h> #include <iostream> using namespace std; int main() { SHFILEOPSTRUCT … | |
Re: Repost your question [URL="http://forums.macrumors.com/forumdisplay.php?f=73"]here [/URL]-- it is specifically for mac | |
Re: I just gave you more rep to see if that would change it, but that didn't help either. | |
Re: don't know, unless its because you missed a \ in line 1 just before My Documents. VC++ 6.0 is a very very old compiler that may, or may not support that import statement. | |
![]() | Re: You can hide the console window if you want to. In MS-Windows you have to use win32 api functions to do it. [code] #include <windows.h> int main() { HWND hWnd = GetConsoleWindow(); ShowWindow(hWnd,SW_HIDE); } [/code] ![]() |
Re: if you are using read() to read the data, then immediately call gcount() to get the number of bytes that were read. tellg() will only tell you where the file pointer is, not how many bytes were read. | |
Re: >>How this while is executed? Its an infinite loop because fgets() never returns EOF. fgets() returns NULL when it reaches end-of-file | |
Re: >> I'd like to use char arrays for this, not c strings if possible. They are the same thing in C language. If you want to keep all the tokens (or words) in memory for all lines of the file then just generate a linked list of them. [code] struct … | |
Re: >>If you cannot log in, please email me at [email]cscgal@daniwebmail.com[/email] ... Thanks!!!!! That's a bit like the message "keyboard undetected -- press any key to continue" :) | |
Re: line 23: sizeof(& file_F)); That is returning the size of a pointer, not the structure. Remove the & address operator. | |
Re: With a MS-Windows 32-bit (or 64-bit) compiler you will have to use the console functions in windows.h to get and set the current cursor position. Something like this: [code] #include <Windows.h> #include <stdio.h> void gotoxy(int x, int y) { // set the current cursor position COORD coord; coord.X = x; … | |
Re: what do you mean by "native code"? | |
Re: Although that may have answered your question, I hope you realize that article is 8 years old and we now have Windows 7. I think w2K was the first Microsoft operating system whose hard drive didn't crash often. I don't think I've had a problem with NTFS since then (knock … | |
Re: I used VC++ 2010 Express and did not get that link error. All I added was this to the bottom of what you posted (after the #endif) [code] int main() { ArrayList<int> a; } [/code] | |
Re: >>void main() main should never be declared like that. The only acceptable way to declare it is [icode]int main()[/icode] or [icode]int main(int argc, char* argv[]);[/icode] what is [b]userinput[/b]? It has not been defined. Your compiler should have produced an error on that line. If you ignored the error than shame … | |
Re: >>what are DLL's Libraries of functions that are shared among all processes and threads which greatly reduces the amount of memory that program consume. If it were not for DLLs every program on your computer would be at least tripple its current size. >>what exactly is a kernal The operating … | |
Re: If your project contains lots of *.c and/or *.cpp files with lots of includes that are common among all of them then using precompiled headers will help speed up the compile process. How to do that, if it can be done at all, will depend on the compiler you are … | |
Re: The compiler will generate a pointer to the first character of a character array if all you pass is the array name, The & symbol is optional. If you want a pointer somewhere else in the array then you have to use the & operator and tell it which byte … | |
Re: First of all you will need to use a database to save all that appointment stuff. The database can be as simple as a text file or as complex as an SQL compliant database such as Microsoft Access, SQL Server, Oracle, Sybase, etc (there are quite a few of them). … | |
Re: According [URL="http://www.liutilities.com/products/winbackup/filextlibrary/files/STF/"]to this [/URL] [quote] The .STF file extension identifies a Setup Information file which relates to Microsoft's Setup procedures and may contain tabular index information for use by this function.[/quote] You probably need some sort of Microsoft Installer program to generate that file. | |
Re: I think you would have more success by reading the entire line with fgets() then just write the line into the output file starting with the 3d byte of the input buffer [code] char inbuf[255]; while( fgets(inbuf, sizeof(inbuf), Numbered) != NULL) { fputs(&inbuf[2], Filtered); } [/code] | |
Re: why do those two functions have arguments? Did your instructor tell you to do that? Move lines 4 and 5 down into main() before calling either of those two functions, delete lines 11 and 12, then you can use the same variables for both functions on lines 32 and 34. … | |
Re: >>close(mfdprot); You probably meant fclose(mfdprot) Sounds like your operating system is buffering up the data. Try adding fflush() before fclose(). | |
Re: 32-bit compilers such as Dev-C++ do not support any of the functions in dos.h. Those functions won't work on MS-Windows operating system since Win98 (10-20 years ago). | |
Re: MessageBox.Show() has several overloaded functions. [URL="http://msdn.microsoft.com/en-us/library/system.windows.forms.messagebox.show.aspx"]Read the list here [/URL]and you will see how to do that. As for books -- search amazon.com and you will find them. | |
Re: Look carefully at those while loops. See anything strange (wrong) with them? Take the first set of while loops. The first thing that will happen is that inFile6 will read the entire file while inFile3 and inFile4 remain constant (they won't read any more. After inFile6 reaches end-of-file the inFile6 … | |
Re: Opening an image file in C language is no different than opening any other file. Its what you want to do with it after that which can get tricky. Either your instructor is very very stupid or just didn't want to be bothered with your question. And yes, you can … | |
Re: >>However, we allow the [color] bbcode to be used within code tags that are not syntax highlighted to point out specific items. only [noparse][color=red][/noparse] works. Other colors are ignored. | |
Re: Actually, the loops in both code snippets are wrong. Why? Because eof() doesn't work like that. It only detects eof-of-file AFTER an attempt has been made to read the last item in the file, so the last item will get processed twice. A better way to code it is like … | |
Re: #1: [code] int fact = num; for(int i = 2; i < num; i++) fact *= i; [/code] | |
Re: first you need to get the mathametical formulas for those. toupper() and tolower() has nothing to do with that. Once you know that you can start writing the program. Nobody here is going to do that work for you, so post some code and ask all the questions you need … |
The End.