15,300 Posted Topics
Re: if you want to use strcpy() just do this: ` strcpy(p->name,input_name);` > gets(input_name); Never call gets() because it will allow you to enter more characters then the buffer can hold. All excess characters are just scribbled all over your program's memory. Instead, call fgets() like this: `fgets(input_name, sizeof(input_name), stdin);` <<< … | |
Re: 1. because it's in the std namespace, as are all the other classes in the fstream and iostream header files. 2. dont' know, but Mike probably does 3. Yes, because they are implemented by different compilers. The same iostream is implemnentsed by all c++ compilers, that doesn't mean they are … | |
Re: Sorry, but killing someone is never funny or humorous, except maybe in a cartoon like RoadRunner where the person or other living creature is not really killed. | |
Re: Are you trying to tell us that when the ink carterage runs out of ink we should just buy another printer a couple hundred dollars instead of a new ink carterage for $25.00USD? | |
Re: we are not going to just hand you the code, but will be glad to help you with your program. What exactly don't you understand? Have you read your textbook about file handling? Have you used google to search for "fstream tutorials"? I suspect not. | |
Re: This is one of the few times C and C++ are different, at least in older versions of C. At one time NULL was defined as (void \*)0 e.g. `#define NULL (void\*)0`, so it was an error to assign NULL to a non-pointer. Turbo C still uses that since its … | |
Re: Are you looking in the right column? I'm #36 in the list today and you are #2. | |
Re: int main() { college student ={"james", "carter"}; printf("%s %s ", student.name); getch(); } | |
Re: You can always turn on invisibility mode in your Profile then you won't appear in the activity stream. | |
Re: You shouldn't say "Hollywood" and "morals" in the same sentence :) Hollywood lost all morals years ago when they started producing R rated movies which contain lots of violence, cursing and sex. | |
Re: You mean you want to work on your vacation? Take some time off from programming and do something else, like skiing, sky diving, or scuba diving. Or just relax, go to the beach and watch the girls go by. | |
Re: >I would be in favor of a feature similar to "flag bad post" but for an edit request, for small edits like fixing formatting. You mean we can't do that now??? Just hit Flag Bad Post and comment "add code tags" or some other editing problem. I don't like the … | |
Re: line 2: how is variable file declared? If it is std::string, you can't do it that way. file += ".txt" infile.open(file.c_str()) if file is declared as a character array do this: strcat(file,".txt"); infile.open(file); Your program doesn't need that for next loop. Just a while loop will do ok while(true) { … | |
Re: You will have a lot easier time reading/writing the Movie structure if you replace the std::string with char arrays, something like below. std::string can not be easily written to binary files. In c++ program I like to use a constructor to initialize the data rather than initializing the data in … | |
Re: You probably can't get legal license for VS 2008 any more, get VS 2012 Express editiion is free for both personal and commercial use. But I suspect your hardware isn't large or fast enough. [Here](http://msdn.microsoft.com/en-us/library/4c26cc39(v=vs.90).aspx) is a link to VS 2008 hardware requirements. I think you can use your current … | |
YouTube video I just saw http://www.youtube.com/watch?v=20MCxSFgrnc&feature=related | |
Re: Doesn't really matter because the world is coming to an end in 13 days (21 Dec). :) | |
Re: Since you are new to win32 you should have read [this tutorial](http://winprog.org/tutorial/) Use [TextOut()](http://msdn.microsoft.com/en-us/library/windows/desktop/dd145133(v=vs.85).aspx) for drawing text in a window. [ Her](http://www.youtube.com/watch?v=PxSY4697w3A)e is a YouTube video that shows how to use it. [Here](http://msdn.microsoft.com/en-us/library/windows/desktop/dd144821(v=vs.85).aspx) is a list of all the font and text functions that you can use | |
Re: probably because you didn't write code to do it. Sorry, but a vague question deserves a vague answer. | |
Re: The const return value in that example is pointless and does nothing. The time to use const return value is when the method is returning a reference or pointer to one of it's data items, assuming you don't want the calling function to change the value. class foo() { public: … | |
Re: The vector will be slightly larger for the class's other data members. But the array of integers will be the same size. If you don't need the methods of a vector them use a normal array. | |
Re: What you want is the win32 api function [SHGetSpecialFolderPath()](http://msdn.microsoft.com/en-us/library/windows/desktop/bb762204(v=vs.85).aspx). This function is used to get path to several different operating system-dependent paths. For example if you want the path to "c:\Program Files(86)". The macro in the 3d parameter is defined in [this list](http://msdn.microsoft.com/en-us/library/windows/desktop/bb762494(v=vs.85).aspx). char path[MAX_PATH]; SHGetSpecialFolderPath( 0, path, CSIDL_PROGRAM_FILESX86, FALSE … | |
When my program calls MsgBox it appears in the middle of the monitor. Anyone know how to move it somewhere within the boundries of my program's window? | |
Re: Please post the Horse and Track classes. | |
Re: ListBox.SetSelected -- [click here](http://msdn.microsoft.com/en-us/library/system.windows.forms.listbox.selecteditem.aspx) | |
Re: Start out very simple by counting the number of letters in a sentence. When you get that finished and tested then you can write the code to count the number of words. Do just one part of it at a time so that you don't get overwhelmed by the complexity. … | |
Re: line 31: num<=num That makes an infinite loop because num will always be equal to itself. | |
Re: why are you using an online compiler? There are several free compilers that you can download and compile on your computer, assuming you are using your own computer instead of one located in some public place like a library or at school. | |
Re: Can you be more specific? What events? How is the ActiveX control written (MFC, ATL, or something else (what))? If the callback function is a member of a class then it must be a static method, otherwise it must be a global function. | |
Re: line 59: notice the pointer is local to the constructor. As soon as the constructor ends the pointer goes away and all memory alloted to it is lost (memory leak). Correct the problem by allocating memory for the pointer that is declared in the class, like this: ` this->Participants = … | |
Re: You need to pass a pointer to the struct declared in main(), not the struct itself. Since you declared students as an array of structs you have to tell ypologismoi() which one it needs. For example: `ypologismoi(inArxeio,&students[0],&p100,&pAll); ` If your intent is to pass the entire array, then change the … | |
Re: First use ifstream object to open the file for reading. In a loop use ifstream's >> operator to read the data into each variable That's the best advice I can give you since you failed to tell us anything at all about what you have done so far to solve … | |
Re: [Here](http://www.codeproject.com/Articles/662/A-Beginner-s-Guide-to-the-Linked-List) is a beginners guide to linked lists tutorial. | |
Re: What programming language are you writing the program? | |
Re: >Now, my first question is, do I try and run the 'burger.c' file or do i compile the created 'burger.o' file because when I try the .o file it says 'cannot execute binary file'. you don't do either. You can only run the executable. Add the -o filename to the … | |
Re: Did you compile the program? Are there any compiler errors? If yes, then list a few of them. If not, did you try to run the program? Does the program produce the correct results? | |
Re: lines 52 and 58 attempt to declare variables with the same name. Variable names must be unique. | |
Re: check the return value of fopen() -- its probably failed to open the file. Does the file exist in the current working directory? | |
Re: Instead of reading the file one character at a time, read an entire line at once and then parse it to break it up into its individual parts. std::string line; while( getline(infile,line) ) { // now break the line into its individual parts } | |
Re: There is a time limit, after that you can't edit the post. Just add another post to explain the correction. | |
Re: For lines 15 and 16 it is not possible to get the length of the string because neither string is NULL-terminated. If you ended each of those strings with '\0' then func() could call strlen() to get the length of the strings. In any event, its impossible for func() to … | |
Re: >The consequence of that 1 downvote cause this person to downvote me 930 times for what? I thought there was a limit for the maximum times a member can up/down vote another member in the same day? Were all those downvotes on the same day? | |
| |
Re: What compiler and os are you using? Are you using MFC (Microsoft Foundation Class), Windows Forms, or some other GUI (tell us which one)? | |
Re: maybe there is a space after the second / in the last line. Leave off looking for '\0' and just check the first two characters. | |
Re: >I'm just having a heck of a time trying to figure our the answer(s) to the following questions Those aren't questions -- they are problems for you to do. Start by doing the first problem, then when that is finished do the second, etc. When you get one that you … | |
Re: [Here](http://www.programmingforums.org/post191089.html) is a working code snippet. Just remove the const keyword when declaring data should solve the problem. `char data[] = "Callback Function called";` | |
Re: Do you want to change the wallpaper on the computer? [Here is a code snippet.](http://www.daniweb.com/software-development/cpp/threads/245580/vc-set-desktop-wallpaper-win-7-x64-) that works for Windows os. | |
Re: Post the code you have written so that someone can help you with any questions you may have. No one is going to just give you the solution to the program. |
The End.