1,174 Posted Topics
Re: Your [ICODE]duplicate()[/ICODE] methods are consistently wrong. Instead of passing an address of an object on stack like you do, allocate the object from the heap using [ICODE]new[/ICODE] and return the pointer to it. For example .. [code] shape *duplicate() { return new square(length); } [/code] And once you've done with … | |
Re: By leaving the nullified pointers in the vectors, the second time around you iterate over the vectors, a crash is more than likely to happen (assuming these indices remain NULL pointers). Also you may want to check what the destructors are doing. [EDIT] Oh, and please read [URL="http://www.daniweb.com/forums/misc-explaincode.html?TB_iframe=true&height=400&width=680"]What are code … | |
Re: Are you aware of (all) the [URL="http://msdn.microsoft.com/en-us/library/cc144200%28VS.85%29.aspx"]autorun.inf entries[/URL] and what you can do with them. I'm not 100% sure, but I think you might very well do without any extra compiled executable on the CD. If you still think you need this executable, what exactly would this executable do? Ancient … | |
Re: [QUOTE=mariosbikos;1199292] in my mind my code is right but windows say no.....[/QUOTE] You want to check your [URL="http://www.cplusplus.com/reference/clibrary/cstdio/scanf/"]scanf()[/URL] usage. Most of them seem to be right but some are dangerously wrong. For example; [code] // A single char char apantisi; ... // '%s' expects an array of char (i.e. a … | |
Re: Your compiler may have a [I]verbose[/I] option (i.e. some switch), which would enable you to see where it is actually looking for the include files. | |
Re: You cannot a pass an iterator to [URL="http://www.cplusplus.com/reference/stl/vector/at/"]at()[/URL]. Read up about its parameter. | |
Re: I think the [COLOR="Red"]trouble is[/COLOR] due to [ICODE][COLOR="Red"]const[/COLOR] vector<double> &GetData()[/ICODE]. | |
Re: [QUOTE=PTRMAN1;1204228]the output program at the end is blank.[/QUOTE] The input file is not opened? You might use [ICODE].is_open()[/ICODE] to check that. | |
Re: [QUOTE=SacredFootball;1204249]what the heck is going on?[/QUOTE] [code] cout << "Your score is: " + finalPoints_ [/code] You want to change the '+' there to something else. | |
Re: [quote] SOLVED IT!: added fflush(stdin); [/quote] Oh no, perhaps reconsider and find another solution to the problem, read e.g. [URL="http://www.gidnetwork.com/b-57.html"]Things to Avoid in C/C++ -- fflush(stdin)[/URL] | |
Re: One basic Windows tutorial is [URL="http://www.winprog.org/tutorial/"]theForger's Win32 API Tutorial[/URL] | |
Re: In the derived constructors, you want to to pass the [ICODE]pID[/ICODE] to the base class. | |
Re: [QUOTE=aae005;1203764]i am new at c++ so plz help me to solve this home work i need marks plz [/QUOTE] You should be paying more attention to the assignment. You are required to write C programs (not C++). You might also read [URL="http://www.daniweb.com/forums/announcement8-2.html"]We only give homework help to those who show … | |
Re: Introduce a new scope {} inside the case, like so .. [code] switch (service) { case 'D' : { // new scope begins .. ... your code here as is ... } // .. and ends case ... [/code] | |
Re: Line #12, [ICODE]subhkey[/ICODE] would be used uninitialized at that point, even if your class declares a member: [ICODE]HKEY subhkey[/ICODE]. Then, are you sure you posted the actual code, I think, [ICODE]open_key(hkey[/ICODE] should rather read [ICODE]open_key(hKey[/ICODE]? >> but what he does is enumerate twice the subkeys of the HKEY_CURRENT_USER Perhaps post … | |
Re: [QUOTE=mebob;1192996]I ran it in debug mode, and it said there was a segfault. When it told me where the error was, it was in the ostream header file. Now what do i do?[/QUOTE] At least one out-of-bounds (13 vs. 28) write .. [code] float percent[13]; ... for ( i = … | |
Re: Looks like you are doing something like [code] ifstream ifs("foobar"); char chr[1]; // Read a char ifs.get(chr); [/code] Just change to plain char, i.e. [code] ifstream ifs("foobar"); char chr; // Read a char ifs.get(chr); [/code] | |
Re: [QUOTE=Sir Saula;1199327]It does work but when the word is being read from a file and then passed into that method it does not properly remove the [I]punctuation[/I].[/QUOTE] Looking at the code you've posted (post #6), I notice that you've removed the following line .. [code] x.erase(std::remove_if(x.begin(), x.end(), &ispunct), x.end()); [/code] … | |
Re: An additional thing that looks real bad and may be contributing to your problems .. [code] fflush(stdin); [/code] you might read [URL="http://www.cprogramming.com/faq/cgi-bin/smartfaq.cgi?answer=1052863818&id=1043284351"]Why fflush(stdin) is wrong[/URL]. | |
Re: The [ICODE]print()[/ICODE] method in the [ICODE]Book.h[/ICODE] is lacking a '}'. | |
Re: Line #115, should it rather read [code] case 3: ofBB.push_back(row[COLOR="Red"]b[/COLOR][jb]);break; [/code] | |
Re: The code you've posted will not even compile (snippet #1/line #11). So, maybe post the exact code that you are actually using. | |
Re: Consider the following .. [CODE] struct foo { float f1, f2, f3; // Accept a pointer to an array of 3 floats foo(float (*f)[3]) { f1 = (*f)[0]; f2 = (*f)[1]; f3 = (*f)[2]; } private: // Hide the unsafe constructor foo(float *); }; // And use it like .. … | |
Re: >> for some reason when i run it the command prompt appears blank. You have forgotten to use [ICODE]account_details()[/ICODE]. | |
Re: [QUOTE=tarheelfan_08;1190038]What do you mean, my CarList stuff is after my car class set up..is this incorrect??[/QUOTE] At the moment, your [ICODE]CarList[/ICODE] only has a constructor defined, all member methods (e.g. [ICODE]void insert(Car)[/ICODE]) lack the implementation (or you haven't posted all of the code). Then a thing that is quite wrong … | |
Re: Lines 31 and 33 are assignments instead of comparisons. PS. In the future, try to be much more detailed than just stating "code is not working". | |
Re: [QUOTE]MRKtack.exe!VisualEditBox::LineMinMax+0x6a MRKtack.exe!VisualEditBox::Refresh+0x7e MRKtack.exe!VisualEditBox::InternalPaint+0x3b MRKtack.exe!SelectEditBox::MouseSetCaret+0x242 MRKtack.exe!UndoEditBox::MouseSetCaret+0x14a MRKtack.exe!SelectEditBox::StartSelection+0x40 MRKtack.exe!EditBox::wmLbuttondown+0x130 MRKtack.exe!WndProc+0x2bd USER32.dll!UserCallWinProc+0x18 USER32.dll!DispatchMessageWorker+0x2e4 USER32.dll!DispatchMessageW+0xb MRKtack.exe!Window::MessageLoop+0x5f MRKtack.exe!Window::Run+0x2b MRKtack.exe!WinMain+0x82d MRKtack.exe!__tmainCRTStartup+0x286 MRKtack.exe!WinMainCRTStartup+0xd KERNEL32.dll!BaseProcessStart+0x3d[/QUOTE] To point out at least one immediate problem, it gets 'stuck' in the [ICODE]LineMinMax()[/ICODE] doing some lengthy calculations there. When it stops responding, break it into the debugger and watch the values being … | |
Re: I don't know much about SDL programs' behaviour and possibilities, but I noticed that you do a [ICODE]exit(0);[/ICODE] there (line #50). In practice, no code that you have below that line will get executed, see [URL="http://www.cplusplus.com/reference/clibrary/cstdlib/exit/"]exit()[/URL]. Perhaps you should find a SDL forum for SDL-specific questions. | |
Re: Both of your [ICODE]for()[/ICODE] loops end with a semicolon, that's a huge problem. Delete those semicolons and see how it changes the outcome. | |
Re: Try the following, in the dialog box's [icode]OnInitDialog()[/icode] handler .. [code] CDialog::OnInitDialog(); SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE); [/code] [QUOTE] Additionally if there was a way it could [I]always be on top of other programs but still be minimized[/I], that would be even better.[/QUOTE] Sorry, but I don't quite understand … | |
Re: Somewhat off-topic, only related to this zero-length thing, here is Herb Sutter's take on it [URL="http://herbsutter.com/2009/09/02/when-is-a-zero-length-array-okay/"]When is a zero-length array okay?[/URL] | |
Re: As to the original 'problem', would [ICODE]goto[/ICODE] be accepted? | |
Re: Considering using [ICODE]fflush()[/ICODE] to have the output printed immediately [CODE] fprintf(stdout,"Hey guys.."); /* force the output onto the screen .. */ fflush(stdout); struct timespec t_req, t_rem; t_req.tv_sec = 1; t_req.tv_nsec = 500; if (nanosleep(&t_req, &t_rem) < 0) return 0; fprintf(stdout,"...What's up?");[/CODE] | |
Re: You might use a [URL="http://www.cplusplus.com/reference/iostream/stringstream/"]stringstream[/URL] for that purpose. This has been answered probably a gazillion times, here we go again .. [code] #include <iostream> #include <string> #include <sstream> int main() { std::string filename ("data"); std::string extension (".txt"); std::stringstream sstrm; for(int X=1;X<11;X++) { sstrm << filename << X << extension; std::cout … | |
Re: [QUOTE=bandit711;1186732]i come up with a additional set of numbers, but i don't know why.[/QUOTE] Line #44 needs rewriting [code] while(inFile) [/code] Change it to .. [code] while(inFile >> studentName >> quiz1 >> quiz2 >> quiz3 >> quiz4) { // rest of the code ... } [/code] Your [ICODE]while(inFile)[/ICODE] is a … | |
Re: [QUOTE=xofth;1185903]my question is still there that how can i place check on the input that user can enter only 'y' or 'n'[/QUOTE] Consider using logical AND (&&) .. [code] do { prompt the user .. get the input .. } while(ans != 'y' && ans != 'n'); [/code] or logical … | |
Re: You need to use the [ICODE]KEY_ENUMERATE_SUB_KEYS[/ICODE] flag when opening the key .. [CODE] // .. if(RegOpenKeyEx( HKEY_CURRENT_USER , "Software" , 0 , KEY_ENUMERATE_SUB_KEYS | KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS) { // .. [/code] Note that a successful [ICODE]RegEnumKeyEx()[/ICODE] call will change the value of the [ICODE]size[/ICODE] parameter to be the length … | |
Re: See the documentation on [URL="http://msdn.microsoft.com/en-us/library/aa384702%28VS.85%29.aspx"]InternetGetConnectedState()[/URL] The first parameter is a[I] pointer to a DWORD[/I] (i.e. [I]LPDWORD[/I]), which receives one or more of the flags, as described. So, rather use .. [code] DWORD dwFlags; BOOL bState = InternetGetConnectedState(&dwFlags, 0); // .. check the state + the flags [/code] It seems to … | |
Re: [QUOTE=theABCasian;1180647]should be initialized in constructor[/QUOTE] I think you are still missing the point that jonsca has been making about [I]static[/I] member variables, perhaps see C++FAQ [URL="http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.10"] [10.10] Why can't I initialize my static member data in my constructor's initialization list?[/URL], and read the next one [10.11] too. | |
Re: Adding to what's been said, just in case anyone is interested in trying out the code. This [code] printf("Enter name (ENTER only will exit) : "); scanf("%s",str); [/code] will not work as intended, i.e. just pressing ENTER without any other input does not make [ICODE]scanf()[/ICODE] return. With the original [ICODE]gets()[/ICODE] … | |
Re: [QUOTE=spursfan2110;1175597]Actually, to be more specific, it appears to happen immediately before the free(cur) would be executed...which seems even odder to me.[/QUOTE] Likely you are [I]writing to already freed memory[/I], outside this [ICODE]delete_from_list()[/ICODE] function. The debug memory management facilities kick in upon the attempt to [ICODE]free()[/ICODE], catching the aforementioned error (-> … | |
Re: [QUOTE=mucoool;1172780]char text[10][/QUOTE] You need to increase the size of that array by one, if you intend to copy a literal such as "0x00000000" into it (you must account for the terminating '\0' character). Otherwise, you'll be writing out of bounds, which is not allowed. PS. Maybe consider using [ICODE]std::string[/ICODE]s instead … | |
Re: Consider switching to [ICODE]unsigned char[/ICODE]s altogether, or at the minimum, cast to [ICODE]unsigned char[/ICODE] whatever you pass to [ICODE]isdigit()[/ICODE]. PS. When you post code/error messages, please tick the "Disable smilies in text" option before you post (see your second post ^^). | |
Re: [QUOTE=urbangeek;1173997]correct me if i'm wrong [CODE] double celsius; printf("%[COLOR="red"]lf[/COLOR] temperature in celsius",celsius); [/CODE][/QUOTE] I think it was Dave Sinkula who once corrected me about this printf/double and %[COLOR="Red"]l[/COLOR]f. That line should rather read .. [code] printf("%f temperature in celsius", celsius); [/code] In C99, the [ICODE]printf("%[COLOR="Red"]l[/COLOR]f")[/ICODE] should have no effect, though … | |
Re: [QUOTE=mrnobody;1171904] If I use OnCtrlColour handler, when is the function called..? Is it everytime the the dialog is reload/refresh or is it continuously called independent of what I do..?[/QUOTE] MSDN says; "The framework calls this member function when a child control is about to be drawn." In practice, this means … | |
Re: If you already haven't, then try debugging the constructor, that is, place a breakpoint at the following line and take it from there .. [code] TextureName = strlwr(strdup(Filename)); [/code] | |
Re: [QUOTE=tallygal;1170780]Thanks... I changed it to this, but it still [I]is not reading the if statements[/I][/QUOTE] You are using uninitialized variables local to the functions, consider the following ... [code] void decline () { char letter, // <- A local variable, uninitialized status; // <- A local variable, uninitialized // See … | |
Re: [QUOTE=Pynolathgeen;1171525] [code=C++] Oldproc = (PROC)SetWindowLong(Childs[1], GWL_WNDPROC, (DWORD)EditProc); [/code][/QUOTE] You might want to check that [ICODE]SetWindowLong()[/ICODE] actually succeeds. And while you are at it, you might switch to [URL="http://msdn.microsoft.com/en-us/library/ms644898(VS.85).aspx"]SetWindowLongPtr()[/URL] altogether (it supersedes the former). | |
Re: Have you considered using STL containers instead? Such as [URL="http://www.cplusplus.com/reference/stl/vector/"]vector[/URL]<ICOMInterface*> or [URL="http://www.cplusplus.com/reference/stl/list/"]list[/URL]<ICOMInterface*> for example. |
The End.