15,300 Posted Topics
Re: use a linked list of structures. Read a value from the file, search the list to see if its already in the list. If found just increment the count. Otherwise if not found then add a new node and initialize the count to 1. Note: for [b]value[/b] in the below … | |
![]() | Re: What? there is nothing to correct because the function [b]even[/b] already returns true or false, unless you just want to rewrite it like this: [code] bool even(int x1) { return (x1%2 == 0) ? true : false; } [/code] ![]() |
Re: line 12: should be this: [icode]while(p)[/icode] Your program gets segment violation when strtok() returns NULL. >>I realize its probably overkill for my purpose so if anyone could point me to a simpler solution that would be appreciated too. In C language that's about the best anyone can do. | |
Re: how about a linked list ? or something like this: [code] void foo(int x) { int n = 0; cout << "Enter a number " << x << ":\n"; cin >> n; if(x < maxNum) // maxNum declared elsewhere foo(x+1); cout << "n = " << n << "\n"); } … | |
Smiles list in the advanced edit window often does not work -- it does nothing. Sometimes when it does work the list is generated below the edit window (see thum) and I have to scroll down to see them all . I've noticed this behavior in only the last few … | |
Re: The first line initializes the values of the array. The second line is a syntax error. It should be [icode]int* ptr = &array[0];[/icode] The last line sets the value of te first array element to -1. | |
Re: If you are taking an assembly class why are you wrinting C program? How write to the screen that depends on the operating system you are using because each one is different. For MS-DOS, [URL="http://spike.scu.edu.au/~barry/interrupts.html#ah2c"]start here[/URL] | |
Re: see the answer [URL="http://www.programmingforums.org/thread14600.html"]here[/URL] | |
Re: If you want [b]findMax() to change the value of ptr in main() then you have to pass the parameter by reference and not by value. [code] void findMax(int arr[], int n, int** pToMax) { ... *pToMax = &arr[0]; } int main() { ... findMax(nums, 4, &ptr); } [/code] Or since … | |
Re: Your code formatting is absolutely horrible! Completly unreadable. And that is probably why you don't understand the error. Reformat it, indent it properly, and you will probably see the problem. And don't be afraid to put { and } on their own separatelins, unlike the horrible code in line 122. | |
Re: This is one way to do it. [code] int main () { float f = 123.457678F; int a = (int)f; float b = f - (int)f; if(b > 0.5F) a++; cout << a; return 0; } [/code] | |
Re: on MS-Windows fopen() returns NULL on error, which it should do on all other operating systems. | |
Re: Of course nothing happens because there you did not post any executable code. All you have is a structure and a function prototype. also try reading some of [URL="http://www.google.com/search?hl=en&q=how+to+create+icon+in+system+tray"]these google links[/URL] | |
![]() | |
Re: >>that means tells the operating system a program finish? No. There is other code that you did not write that does that. main() returns not to the os but to the start-up code that called main(). What that startup code does is not specified by standards and is therefore different … | |
Re: Line 17 should be moved to the first line of main() because srand() should be called only once throughout the lifetime of the program. lines 17-21: If you want to keep asking the questions then why didn't you use a [b]while[/b] loop here ? The [b]if[/b] will execute it only … | |
Re: Your score is 10 on a scale of 1 to 10. You are a True Believer in President Bush. Your loyalty and devotion to him is matched only by your desire to see his liberal detractors locked away and declared enemy combatants. Given the chance, you'd gladly vote Bush a … | |
Re: The problem is that we don't know if that great nothingness still exists. If it took one billion years for us to see the void then it will take at least another billion years to find out if it was ever filled with anything. Maybe right now that void is … | |
Re: [QUOTE=twomers;433109]>> I >> Who are you saying is right? Jail over bad food ... I think there's no question about that who's in the wrong there. I misread and thought the worker was still in prison.[/QUOTE] Yes, if it is known that an employee deliberately and malitiously put poison in … | |
Re: You are confusing a vector of ints with a vector of student_record classes. [b]ex[/b] is an array (or vector) of integers, not student_record classes. And that's why your compiler is complaining about lines 32 and 33. [edit]^^^^ what Duoas said more detailed than what I said[/edit] | |
Re: correct the compiler errors and warnings. Below are the ones I get. I realize you might not be using the same compiler but you should have gotten similar errors. error C3861: 'counter': identifier not found error C3861: 'incorrect': identifier not found error C3861: 'correct': identifier not found | |
Re: can't help you, sorry. You are using too ancient a compiler, non-standard header files and obsolete stream header files. Delete dos.h and conio.h, then replace <iostream.h> with <iostream> and replace <fstream.h> with <fstream> then maybe, just maybe people might be able to help. | |
Re: I don't see anything that would cause the problem you report, but I do see problems with that [b]square()[/b] function. In main() if you first select 'S', the value of the three variables are all 0. I don't know what [b]minMax[/b] does, but assume it finds the minimum and maximum … | |
Re: see [URL="http://www.google.com/search?hl=en&q=linked+list+in+c&btnG=Google+Search"]these google links[/URL] | |
Re: I can understand your confusion. >>Loops and other non-sequential code are still involved, but occur in the operating system rather than the program that you write Wrong. I think that paragraph is attempting, though somewhat poorly, to describe the difference between [b]procedural[/b] and [b]event-driven[/b] programs. A [b]procedural[/b] program is executed … | |
Re: The second parameter to OpenData() should be char* not simply charf [icode]void OpenData(int ** arrayPtr, [color=red]const[/color] char[color=red]*[/color] file, int *arraySizePtr )[/icode] Didn't your compiler give you a bunch of errors because of that? There are several other syntax erorrs too, and in some cases you need to add typecasts. | |
Re: Already answered it on the C board, so I'm closing this thread. | |
Re: >>I receive assignments like fix BUGS or write small functions in the projects. Yup, that's the life of a programmer for the first 20 or so years. Much of the time is spent in program maintenance. | |
Re: [QUOTE=bobbyraw;471683]. if they bypass which they will, once they post in the forum a moderator should get a pm and contat .[/QUOTE] I hate that idea! I don't want my PM inbox flooded with all those messages. | |
Re: The only way you could possibly access it is if the variable is global and non-static. In that case you could declare it with the [b]extern[/b] keyword in your program. If your program links then you should be ok. If it doesn't link, then tough luck, you will not be … | |
Re: >>I need some help writing this program Which part are you confused about? We are not going to write the program for you. So you might as well do what you can, post your program, and ask specific questions. The instructions seem to be pretty clear to me. | |
Re: [QUOTE=eren;477247]i did only part of prime number but i haven't got any idea about the other parts you can say only how can i do other parts.. or you can't say.. it's your choice ;)[/QUOTE] You're missing the point -- we are not mind readers so we have no idea … | |
Re: [QUOTE=Jishnu;477818]boyz is banned. I thought this thread would be closed.[/QUOTE] We don't close threads just because the thread starter gets banned. | |
Re: [b]Flights[/b] is a three-dimensional array because it has three stars. If what you really want is a 2d array then remove one of the asterisks in its declaration. | |
Re: Line 53: T is uninitialized so its value is any old random value, including 0. You need to initialize it to some known value on line 51. Using a while statement to read integers here is not a good idea because the >> operator does not stop at end-of-line. Better … | |
Re: [QUOTE=BigBen747;476753]I just want some help.[/QUOTE] Learn to crawl before you can walk. You have to learn the language before you can even think about undertaking such as huge project. The people who wrote those program have years and years of experience. You will only fail miserably if you try to … | |
Re: you need to validate the value of [b]arr_siz[/b] entered on line 26. What happens to your program if I enter 1000 on that line? Or if I enter a negative value ? Your program will die a very quick and ugly death. >>it must work as well on Maximum also … | |
Re: >>How would I go about completing this task? Did you try to compile the program? If you did, what errors did the compiler produce? If you did not compile it, why not? Hint: lines 7, 13 and 14 are wrong. | |
Re: Jishnu: Instead of hijacking this thread you should have used the [b]Flag Bad Post[/b] button. | |
Re: line 27: what is that [b]length[/b] function you are calling? In your program [b]number[/b] is the length of the array so there is no need to call another function just to get that. You don't need [b]total_facts[/b] at all, just replace it with [b]number[/b] on line 28. There really is … | |
Re: moved to c++ board. >>please tell me how to become a member of this tag??? Huh? Have no idea what you want. | |
Re: I think I would use a [b]vector[/b] of structures. You need two structures [code] struct numbers { int saleNumber; float amount; }; struct person { int ID; string lastName; string firstName; vector<numbers> numberList; }; [/code] Now just make a [b]vector[/b] of the above person structor, e.g. [icode]vector<person> personList[/icode] |
The End.