2,384 Posted Topics

Member Avatar for osan

Are you using a debugger? Can you add a few lines of your own code such as [code]if ( Ypix < 0 ) { puts("whoa!"); /* put breakpoint here */ }[/code] Maybe even sprinkle more than one of these around the loops to try to narrow down the search?

Member Avatar for Dave Sinkula
0
289
Member Avatar for no1zson

Read the user input as a string, validate the string according to the specific details for dollar amount entry. Such as, begins with dollar sign, is followed by nothing but digits until a possible decimal point, and then no more than two digits. Or whatever.

Member Avatar for no1zson
0
174
Member Avatar for onaclov2000

Seems more like C++. Do you have a minimal compileable snippet that produces the results you see? [code=c]#include <stdio.h> struct f_c_8 { union { float f; unsigned char c[8]; } u; }; struct f_c_8 Time = {{123.456}}; int main() { fprintf (stdout, "Time: %f\n", Time); fprintf (stdout, "Time: %f\n", Time.u); …

Member Avatar for Dave Sinkula
0
85
Member Avatar for melissa.johns

[ICODE]rand[/ICODE] has [ICODE]RAND_MAX[/ICODE], maybe [ICODE]random[/ICODE] has something similar. [url]http://c-faq.com/lib/randrange.html[/url] [url]http://c-faq.com/lib/rand48.html[/url]

Member Avatar for melissa.johns
0
79
Member Avatar for bishop101

[QUOTE=poncho4all;950549]you could try [code]system("pause");[/code] or [code]#include <conio.h>//this library is needed for getch() getch();[/code] right before the return command on your main[/QUOTE] The [ICODE]system("pause");[/ICODE] version is frequently panned, and [ICODE]<conio.h>[/ICODE]/[ICODE]getch();[/ICODE] is ancient and nonportable. So these "fixes" happen to be pretty low on the totem pole. [url]http://www.daniweb.com/forums/showthread.php?p=780810&highlight=system+pause#post780810[/url] [QUOTE=bishop101;950559]Do I always have …

Member Avatar for Dave Sinkula
0
97
Member Avatar for esesili

[QUOTE=esesili;949125]"[B]patient1.output(cout);[/B]" works correctly it gets [B]doctor_hour_fee[/B] from [B]doct1[/B] object. The problem is at [B]patient2.output(cout);[/B]. When I enter patient information it asks me to enter all member variables of doctor object and it creates a new doctor, so that doct1 and new doctor are different and normally I get wrong answer. …

Member Avatar for Sky Diploma
0
118
Member Avatar for cougarclaws

Add some statements to display various parameters at key points in the function. For example, [code]float wk7recur (float value, int num) { [COLOR="Red"]cout << "wk7recur(" << value << ", " << num << ")\n";[/COLOR] if ( num == 0 ) { [COLOR="Red"]cout << " num == 0\n";[/COLOR] return 1; } …

Member Avatar for cougarclaws
0
111
Member Avatar for imwan

[QUOTE=Salem;948972]IMO, you should learn how to do this kind of thing with a std::string, rather than running to c-style strtok() for short-term convenience. You only typed a few lines, and it blew up anyway.[/QUOTE] [QUOTE=imwan;949004]I have changed my code exactly the way both the replies have said.[/QUOTE] [QUOTE=imwan;949661]still the problem …

Member Avatar for DdoubleD
0
1K
Member Avatar for peter_budo

[QUOTE=happygeek;942810]Looks like someone has taken the daniweb name on Twitter (back at the end of 2008) although the account is hardly active with 1 foreign language post and just the 1 follower.[/QUOTE]*Whew* I had to make sure it wasn't my [URL="http://twitter.com/daniweblog"]Daniweb Twitterbot[/URL]. That description didn't resemble that bot, but I …

Member Avatar for kaninelupus
0
160
Member Avatar for Salem
Member Avatar for red_gal_2005
0
212
Member Avatar for no1zson

[QUOTE=no1zson;941597]Would an "acceptable" use of GOTO be to rerun the entire main loop?[/QUOTE]No. [QUOTE=no1zson;941597]If I make it all the way through my logic, and simply want to start over at the top, would not a simple GOTO back to the top be the best option?[/QUOTE]Try to think about the real …

Member Avatar for hket89
0
150
Member Avatar for daviddoria

[url]http://groups.google.com/group/comp.lang.c++/browse_thread/thread/25bc613dfbf72dc2/be4b67885161b012?ie=UTF-8&q=group:comp.lang.c%2B%2B+const+class+member+constructor+array#be4b67885161b012[/url] [edit][code=c++]#include <iostream> #include <vector> #include <algorithm> #include <iterator> class T { const std::vector<double> DefaultForward; public: T(const std::vector<double> &dfinit) : DefaultForward(dfinit) { } friend std::ostream& operator<< (std::ostream &o, const T& t) { std::copy(t.DefaultForward.begin(), t.DefaultForward.end(), std::ostream_iterator<double> (o, ",")); return o; } }; int main() { const double init[3] = {0.0,1.0,0.0}; const …

Member Avatar for daviddoria
0
152
Member Avatar for el33t

If I rolled a quick "simulation" of these classes as follows, would it help clarify things? [code=cpp]#include <iostream> #include <string> class QApplication // real definition probably in <QApplication> { public: QApplication(int argc, char *argv[]) { std::cout << "QApplication ctor" << "\n"; } }; class QLabel // real definition probably in …

Member Avatar for el33t
0
124
Member Avatar for XodoX
Member Avatar for mrnutty
0
91
Member Avatar for NRaf

[QUOTE=NRaf;943339]It seems that the matrix (int** matrix) is being passed by value; therefore when I play with it in the function, it's changing a different memory location so the original remains unchanged. How can I solve this?[/QUOTE]Either return matrix or pass a pointer to it as a parameter to this …

Member Avatar for Dave Sinkula
0
89
Member Avatar for slayerace180

Dunno if something like this is in the ballpark: [code] for ( int i = 0; i < 20; ++i ) { printGrid2(life); determineNextGen(life,life2); memcpy(life, life2, sizeof life); }[/code]

Member Avatar for Nathan Campos
0
162
Member Avatar for gretty

"[URL="http://c-faq.com/lib/srand.html"]Note also that it's rarely useful to call srand more than once during a run of a program; in particular, don't try calling srand before each call to rand, in an attempt to get ``really random'' numbers.[/URL]"

Member Avatar for Dave Sinkula
0
156
Member Avatar for dgr231

[QUOTE=invisal;939353]You can't simply compare 2 strings with operator ==. There is a function in library <string> called strcmp(). [code] Syntax: int strcmp(string1, string2) Return: Return 1 if string1 > string2 Return 0 if string1 == string2 Return -1 if string1 < string2. [/code][/QUOTE]FWIW, the standard definition for the return value …

Member Avatar for dgr231
1
157
Member Avatar for carlcarman

[QUOTE=Hiroshe;940444][URL="http://www.cplusplus.com/reference/clibrary/cstring/memmove/"]memove()[/URL] does not return anything[/QUOTE][aside]Take a closer look at that linked reference.

Member Avatar for wildgoose
0
128
Member Avatar for jephthah
Member Avatar for annbytes
0
221
Member Avatar for compubaba
Member Avatar for lotrsimp12345
Member Avatar for lotrsimp12345
0
183
Member Avatar for D.JOHN

[QUOTE=poncho4all;940390]you can also use only the [code]fstream test; test.open("name of file") while(!test.eof)//.eof means while is not the end of file. { //condition } [/code][/QUOTE] That would be a step backwards. [url]http://www.daniweb.com/forums/post155265-18.html[/url]

Member Avatar for D.JOHN
0
141
Member Avatar for sdmahapatra

A common way to separate a number into digits is to use [ICODE]%[/ICODE] and [ICODE]/[/ICODE] like this. [code]#include <stdio.h> int main() { int i; for ( i = 1; i <= 100; ++i ) { int value = i; printf("value = %d\n", value); while ( value ) { [COLOR="Red"]int digit …

Member Avatar for mrnutty
0
125
Member Avatar for Hiroshe

[QUOTE=Hiroshe;937036]That would be cheating. :P I want to see what can be done with standard C alone.[/QUOTE]Prepare to be disappointed. ;) [url]http://c-faq.com/osdep/cbreak.html[/url]

Member Avatar for Duoas
0
2K
Member Avatar for newtechie

[url]http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_linklist.aspx[/url]

Member Avatar for newtechie
0
180
Member Avatar for MV89

Is [URL="http://cboard.cprogramming.com/c-programming/118247-mode-array.html"]MV1[/URL] any [URL="http://forums.devshed.com/c-programming-42/mode-of-an-array-629580.html"]relation[/URL]?

Member Avatar for MV89
0
121
Member Avatar for umair125
Member Avatar for Dave Sinkula
0
43
Member Avatar for MrNoob

[QUOTE=MrNoob;938456]now i have my other function which i get runtime error on i don't why though [code] #include <stdio.h> #include <string.h> int ParseCh(char *S,char *buff,int num,char *End) { int i,temp; for(i=0;S[i]!=0;i++) { if(S[i]==',' || S[i]=='\n' || S[i]=='\t' || i==num) { temp=1; End=S+1; [COLOR="Red"]S[i]='\0';[/COLOR] break; } } if(temp) strcpy(buff,S); else { …

Member Avatar for Dream2code
0
231
Member Avatar for jko2326

With the two loops, while and for, you are essentially discarding [icode]pop[/icode] before you get to the for loop. Your if-tree uses [icode]||[/icode] where you mean [icode]&&[/icode]. [code] cout << "\t\t\tPrarieville Population Growth\n"; for ( int years = 1900; years <= 2000; years = years + 20 ) { inputFile …

Member Avatar for jko2326
0
413
Member Avatar for Smoking Bros

What are you doing to tell the difference between "opens the file and then has nothing more to do to closes it and exits the program" and "fails to open the file"? BTW, you may be interested in [URL="http://www.daniweb.com/forums/thread90228.html"]this[/URL] shortly.

Member Avatar for AssaultM16
0
225
Member Avatar for sara9111

[QUOTE=sara9111;936262]What the diffrent bettween while looping, conter-controlled while loop, sentinel-controlled while loop,flag-controlled while loop, do while loop and For loop. when we use each one of them???[/QUOTE]A [ICODE]for[/ICODE] loop tends to lend itself to things which need to be done x number of times: [code]for ( i = 0; i …

Member Avatar for mrnutty
0
132
Member Avatar for shea279

Something akin to [URL="http://www.daniweb.com/code/snippet281.html"]this[/URL]?

Member Avatar for shea279
0
2K
Member Avatar for Pavan_

Once you're off in the land of undefined behavior, strange things can happen. In this case, I believe I need to reverse the declaration order to see which particular thing you may be seeing. That is, [code] int i=0, a[100];[/code] [quote]... 100 101 102 103 6 7 8 ...[/quote]This might …

Member Avatar for Salem
0
129
Member Avatar for taikoprogrammer

> Uhh... what are you doing? pow() returns an integer. [pow](http://web.archive.org/web/20050207005628/http://dev.unicals.com/papers/c89-draft.html#4.5.5.1)

Member Avatar for Dave Sinkula
0
156
Member Avatar for TheWhite

Your pointer is initialized in a screwed-up way. I think you've got bigger fish to fry first. What do you think you're trying to do with your 'bit array' that isn't already done with masks?

Member Avatar for TheWhite
0
1K
Member Avatar for wesduncan

Perhaps keep track of the last non-null string: [code]#include <string.h> int main(void) { char str[] = "now # is the time for all # good men to come to the # aid of their country"; char delims[] = "#"; char *result = NULL[COLOR="Red"], *last[/COLOR]; result = strtok( str, delims ); …

Member Avatar for wesduncan
0
91
Member Avatar for Silvershaft

Hmm. Maybe take a look at [URL="http://eternallyconfuzzled.com/jsw_home.aspx"]the tutorials here[/URL]. ;)

Member Avatar for Dave Sinkula
0
93
Member Avatar for amegahed3

[QUOTE=amegahed3;933998]So?[/QUOTE]I'm guessing that in excess of ~356,400,000 bytes on the stack [I]might possibly[/I] contribute to a stack overflow. [QUOTE=amegahed3;933998]My code (a file called program.cpp) and the .cpp and .h files of the library I'm using are all included in the attached .zip file.[/QUOTE] Maybe not quite all? [quote]hist.cpp In file …

Member Avatar for Dave Sinkula
0
155
Member Avatar for atreyeepal1

[code]for(i=0;i<40;i++)[COLOR="Red"]; /* extraneous semicolon */[/COLOR][/code]

Member Avatar for Dream2code
0
155
Member Avatar for MrNoob
Member Avatar for esesili

[URL="http://www.parashift.com/c++-faq-lite/const-correctness.html#faq-18.10"][18.10] What is a "const member function"?[/URL]

Member Avatar for Dave Sinkula
0
73
Member Avatar for kalodakilla

A brief note on signals and calling standard library functions: [url]http://groups.google.com/group/comp.lang.c/browse_thread/thread/00d5082d648b2437/a4d67511412817da#a4d67511412817da[/url] [edit]Doing some more digging, I found [URL="http://en.wikipedia.org/wiki/Signal.h#Member_functions"]this[/URL]: [quote=Wikipedia]The function func may terminate by executing a return statement or by calling the abort, exit or longjmp functions. [COLOR="Red"]If func executes a return statement, and the value of sig was SIGFPE …

Member Avatar for Dave Sinkula
0
125
Member Avatar for jahmassive

[url]http://forum.codecall.net/c-c/19344-how-redo-same-code-using-structs.html[/url]

Member Avatar for Dave Sinkula
0
487
Member Avatar for jephthah
Member Avatar for jephthah

[QUOTE=jephthah;920287]it's like he just hit the ground and started kicking ass without any warmup period.[/QUOTE]Forums ain't exactly the bleeding edge of teh intertubes. You don't need a "warmup period" when you've already been doing this kinda thing for years (if that is the case, which might be my assumption). ;)

Member Avatar for ~s.o.s~
0
576
Member Avatar for CppBuilder2006

[url]http://www.parashift.com/c++-faq-lite/templates.html#faq-35.13[/url]

Member Avatar for Dave Sinkula
0
107
Member Avatar for msteele
Member Avatar for MosaicFuneral
0
150
Member Avatar for lotrsimp12345

[QUOTE=VernonDozier;923838]I forget the exact criteria where >> returns true and false. I think it may be if any of these three bits are set, >> fails, but don't quote me.[/QUOTE][url]http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.4[/url]

Member Avatar for Dave Sinkula
0
108
Member Avatar for dknoebber

[QUOTE=Ancient Dragon;892346]%i is the same as %d, they are interchangeable but I believe %d is more common.[/QUOTE]They are the same for [ICODE]printf[/ICODE], but they are different for [ICODE]scanf[/ICODE]. Both are used for integers, though. [ICODE]%i[/ICODE] may read the input as hexadecimal or octal as well as decimal.

Member Avatar for DoEds
0
196

The End.