5,676 Posted Topics
Re: The average temp over the past 100 years has increased a whopping 1 degree F. Scary!!! :S So if this uncontrolled rise in temp is not checked, we'll be in danger in about 3564AD. '[I]Global warming[/I]' is a naturally occurring phenomenon that is cyclical. | |
Re: [QUOTE=BestJewSinceJC;733868]From when I programmed in C, I remember that output stream redirection is done by a.out > filename.txt or a.out < filename.txt I don't remember which. One is input redirection, the other is output. I think the first is output.[/QUOTE] 1) Yes, the first one is output 2) How does … | |
Re: Please read [url=http://www.gidnetwork.com/b-58.html]this[/url] about using [ICODE].eof()[/ICODE] the way you are (it's the same as using [ICODE]feof()[/ICODE]. And read [url=http://www.gidnetwork.com/b-38.html]this[/url] about formatting your code so it can be understood. | |
Re: [QUOTE=Ancient Dragon;728164]The code you posted will have undefined behavior. [icode]cube(++x)[/icode] could result in different answers on different compilers, so the ourput can not be determined exactly.[/QUOTE] Why? It increments [B]i[/B], calls [ICODE]cube[/ICODE] with the new value, then returns the answer to [B]y[/B]. What's undefined about it? [B]i[/B] isn't modified twice. | |
Re: No wonder those links don't help. They have nothing to do with the problem. First off, [I]res[/I] is already binary. If you know the shift operator ([B]<<[/B]), that makes it easy to count the 0's. Look it up and see what you come up with. | |
Re: Every solution proposed here has major problems -- that of trying to read an integer when a 'not a number' can be entered which screws up the entire read process.. You need to read [I]an entire line[/I] as a string, test all characters entered up to the '\n' to make … | |
Re: [QUOTE=keyser_soze;726512]i think u might use the getch() putch combination use getch to enter the charcter one by one and then using putch print out * example: [code=c] getch(password[x]); //where x runs in a loop from 0 till NULL putch('*'); [/code] PS:go through this thread [code][url]http://www.daniweb.com/forums/thread9916.html[/url][/code] has a better detailed solution....[/QUOTE] … | |
Re: When you find you have a parameter that starts [B]-t:[/B], use [ICODE]strcpy()[/ICODE]: [code=c]strcpy(websitename, &argv[p][3]);[/code] [B]p[/B] is of course the parameter number [B]3[/B] points to the character after the colon | |
Re: [code] strcpy(input," "); // You don't need to do this if your next // line overwrites the value scanf("%s",&input); // [url=http://www.gidnetwork.com/b-62.html]see this[/url] fflush(stdin); // [url=http://www.gidnetwork.com/b-57.html]see this[/url] [/code] | |
Re: You need to change your increment: [code=c] case 5: //move forward x number of spaces int steps = commands[ ++cmd ]; [/code] This will increment [I]before[/I] you load [I]steps[/I], getting the number of steps. | |
Re: You need to test the value after reading it. If invalid, start the loop. | |
Re: To all of you, floating point values are rarely exact. Therefore testing with == will rarely work. For example, if you entered 46, the actual value stored in the variable might be 46.000001 or 45.9999997, neither of which is equal to 46. | |
Re: [QUOTE=SQ89;723738]Thank YOU :) but can you explain to me how col works?? i mean in the if statement[/QUOTE] Every time you output a number, you increment [I]col[/I]. When [I]col[/I] is 3, 3 number have been displayed (3 cols) so you drop to the next line and reset [I]col[/I] to count … | |
Re: So much help, so little correct :icon_rolleyes: To find the lowest value, store the first value read in a variable, say [I]lowest[/I]. Then for each successive read, test the value read against [I]lowest[/I] and replace if necessary. | |
Re: [QUOTE=kalou;723393] i need a help so badly.[/QUOTE] Then you should have read [I]The Rules[/I] and the post [I]Read This Before Posting[/I] | |
Re: I agree with [B]thwee[/B] -- the [ICODE]for(;;)[/ICODE] is nonsensical. If you are trying to keep your program window open, just do the [ICODE]get()[/ICODE] | |
Re: Did you call [ICODE]srand()[/ICODE] only once? Or every time you called [ICODE]rand()[/ICODE]? | |
Re: Also speak English, not pigeon-speak. And use CODE tags. They are described everywhere on this site. | |
Re: [QUOTE=randika2000e;721714]hay dear i need help for c prog... i used <textcolor (14+128) ,cprint> commands to blink some text. befor i drow rectanngel and some circle as back image. but the text is not apper. if i closed the graphic mood, then it'll show. but i need kept the graphic back … | |
Re: [QUOTE=nimasafa;720264]would please correct it for me and posted in this forum, It's been 4 hours I've working on this but it doesn't work.[/QUOTE] All you have to do is [B]count!![/B] [code]#include <iostream> #include <cmath> using namespace std; void Instructions(); float do_next_op(char op, float o, float CAV); void startCalculatorProgram(); void main() … | |
Re: You might be able to use the built-in functions [ICODE]ispunct()[/ICODE] and [ICODE]isspace()[/ICODE] to 'tone down' some of the long windedness. | |
Re: [QUOTE=Sci@phy;715626] They differ a lot, since turbo c++ compiler is ANCIENT. There is something that is called standard C++ language. It wasn't fully defined at turbo c++ time, so some things that were differently defined don't work nowadays.[/quote] But, for a new student, these differences [I]can be[/I] minor. I rarely … | |
Re: [QUOTE=Ancient Dragon;712707]after entering an integer the program leaves the '\n' in the keyboard buffer. When the next getchar() is called it gets that '\n' from the buffer instead of waiting for user input. To correct this add getchar() after scanf("%d", &consump);[/QUOTE] [QUOTE=cutedipti;714529] See the problem is due to the 'New … | |
Re: Where did you use the variable [icode]index[/icode] to insert the variable [icode]insertItem[/icode] into the array? | |
Re: [QUOTE=ahamed101;713331]As per you, it is C, then this is the right forum... And what makes you say, its c++??...[/QUOTE] The actual questions deal with the calculations, not the output statements. They are fully C++ as well as C. And [ICODE]printf()[/ICODE] is a C++ function. Check any C++ book/tutorial/standard. | |
Re: [QUOTE=ahamed101;710301]Use continue instead so that you can enter the salary again... [code=c] i = 1; while(i <= numb_salaries){ printf("Enter salary #%i: ",i); scanf ("%i", &salary); if(salary < 0){ printf("\n Please enter a valid salary...\n Press enter to re-try..."); fflush(NULL); getchar(); continue; } sal_total = sal_total + salary; i++; } [/code][/QUOTE] … | |
Re: [QUOTE=Sci@phy;706668] [CODE=C] char decision; int flag = TRUE; while (flag){ /*do some stuff here*/ printf ("Do you want to continue (y/n)\n"); scanf("%c", &decision); /*be careful, \n stays in input buffer*/ if (decision == 'y') flag = TRUE; else flag = FALSE; }[/CODE][/QUOTE] What a gross input statement. [url=http://www.gidnetwork.com/b-60.html]See this[/url]. | |
Re: And posts should NEVER be marked urgent! It's not urgent to us -- we'll get to it when we get to it. And many people simply bypass threads titled like this so you've just cut down your chances for help. | |
Re: [B]stilllearning[/B] is correct. The compiler is only interested in the statements that do something so comments are not part of the compiled program. | |
Re: [QUOTE=EBaller55;704374]It would be nice because then I could do the following: [code] for(int i=0, double d=1;i<5;i++,d*=1.5){cout<<"1.5^"<<i<<"="<<d<<endl;} [/code] This would make for cleaner code as it is clear that i and d are used only inside the for loop.[/QUOTE] I disagree. That to me is confusing and unclean. On the other … | |
Re: [QUOTE=Clockowl;702885]On the second page of the thread is a small testing program and some results showing that I only had the problem using fread() on "text" opened files, not on binary opened ones. [/QUOTE] You obviously missed [B]Narue[/B]'s answer to this problem: [QUOTE=Narue;702682][code] size_t n = fread ( buf, 1, … | |
Re: [QUOTE=dspnhn;686435]Good evening..... I just wanted to share an idea.....can this forum be downsized into categories such as API,FORMS,CONTROLS,DATA REPORTS and so on.....the reason i am saying this is people are lost in here....[/QUOTE] Who besides you is lost? Have you tried Hare Krishna...:icon_twisted: (see The Muppet Movie) | |
Re: If the file was included just open the file. If the file was not included, open [I]stdin[/I] instead. [code=c] if (filename_entered) open file else open stdin end if [/code] | |
Re: [QUOTE=grisha83;694490]Anyhow, here is my code and the errors are C2676 and C2784 in Visual Studio[/QUOTE] Since we are humans, not compilers, C2676 and C2784 mean nothing. And even less because we don't know what lines caused the error. Details, me bucko, details. They are important. | |
Re: [QUOTE=lonerider30;694546]To get ths output u will have 2 flush the input buffer after every char input Enter Gender Male/Female(M/F): M Enter Residence City/village(C/V): (it'll not wait here to take i/p & jumps on next line) Enter Health Excellent/poor(E/P): E Enter Age: 25 printf("Enter Gender Male/Female:"); scanf("%c",&gender); //gender is char type … | |
Re: [QUOTE=policeachan;691148]it is known that dennis rithie made c with only 32 keywords and writing functions is the responsibility of the programmer. who wrote the functions printf, scanf?[/QUOTE] Usually the author of the compiler that has the functions defined. | |
Re: Each function and arrow key is really two characters, a \0 followed by another character. Note the code: [code=c] KeyStroke = getch(); if (KeyStroke == 0) { KeyStroke = getch(); switch (KeyStroke) [/code] Get a keystroke with the first [icode]]getch()[/icode] call If that value is a 0, get the [I]next[/I] … | |
Re: [QUOTE=Ancient Dragon;690578]PM your address and I'll mail you a copy of the dvd (yes its a legal copy, I download the ISO fle and made my own dvd).[/QUOTE] Wouldn't it be faster even with dialup to download and burn the ISO instead of waiting for the US Snail? | |
Re: [QUOTE=Trekker182;690711]I have to take a 2d array of [6][8] floats that represent a star map and add the four surrounding numbers to it to measure it's intensity of light. Would something like make sense??? [CODE]for(i=0;i<6;i++) { for(j=0;j<8;j++) { stars[i][j+1] + stars[i+1][j] + stars[i-1][j] + stars[i][j-1];}}[/CODE] instead of writing many lines … | |
| |
Re: What's tha maximum value a [I]signed char[/I] can handle? | |
Re: Nothing else is output to the screen. What do you expect to happen? If you think there's a problem, add a few [ICODE]cout[/ICODE] statements to follow what's happening and pinpoint the problem. And isn't this a C++ program? Why are you using the extremely dangerous C function [url=http://www.gidnetwork.com/b-56.html]gets()[/url] when there … | |
Re: Look into the [I]time[/I] functions in [I]timer.h[/I] for ways to do the counters. If you need help in other areas, please be specific. | |
Re: Maybe for a member's first 5 posts a message displays with the high points of posting and what may happen if ignored. | |
Re: So don't reply again. Edit your post. It's quite simple and proper. | |
Re: [QUOTE=sittas87;672096]and I regard all of that with great respect.but honestly thats life and it wont change.let me put it this way you're on youre way to buy a expensive sofware[witch they always are] and your geeky friend comes over and offer you a cracked version with no prob's to experience, … | |
Re: So we're supposed to write your program because you're in chemical engg? Explain this... |
The End.