- Upvotes Received
- 2
- Posts with Upvotes
- 2
- Upvoting Members
- 2
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
11 Posted Topics
Your do-while loop reads two lines from the file in each iteration: one in the body, and one in the condition. The list gets only three nodes instead of five, and the for-loop then crashes as it tries to read alien memory the third node points to. [QUOTE=gerard4143;1157292]prg1.c: In function …
The problem actually can be solved using real recursion. The function would call itself, with a pointer to the array as an argument. On each subsequent call, the pointer would be incremented by one. The base case is sending pointer to the last element of the array.
You open each file twice: [code]f = fopen (filename, "r"); if ((f = fopen (filename, "r")) == NULL) ...[/code] As far as I understand it, this is a memory leak because your fclose doesn't actually close both of them. I assume that segmentation faults appear when the number of open …
[QUOTE=xavier666;1070819]And can you provide me a link where I can find the problems associated with [icode]scanf()[/icode] and [icode]fflush()[/icode][/QUOTE] And gets(). This shouldn't really be hard to google. For example: [url]http://www.gidnetwork.com/b-57.html[/url]
It's very likely that chandra will take your advice and answer your questions when he comes back. The code was posted in 2004 and his last activity was in february of 2007, but I'm sure it will be soon. :confused:
You do not actually have to save the variable anywhere: [CODE]printf("Enter Any Number & Then Press Enter To Continue ... "); scanf("%*d");[/CODE] Or this: [CODE]printf("Press Enter To Continue ... "); scanf("%*[^\n]");[/CODE] The first scanf() reads one integer and discards it. The second reads input from keyboard until newline is found, …
Everything is possible. ;) You need to loop through the file, scanning each line. When you find the correct line, read the number and store it into the results file. The loop would be very similar to the one you posted, so I assume you have trouble with detecting the …
You don't need to bother with both hours and minutes in every calculation. Instead of saying something like "time-in is thirteen hours and forty-four minutes", you can express it as (13*60 + 44) minutes and work with that one variable. That would make it easier to compare starting time with …
[QUOTE=Gaiety;1041639] printf(" %u\n",&ppvar); ... gives you 2000[/QUOTE] You have one 'p' too many. :) printf(" %u\n",&ppvar); //prints 3000 printf(" %u\n",&pvar); //prints 2000
What exactly happens when you type something in that bar? I assume it opens a browser and searches the internet; if so, which site does it use?
[QUOTE=Dewey1040;831653]ok this code gets three sides of a triangle and prints out the area... but it just prints out that the area is 0 every time... why?[/quote] Because you aren't using data types properly. When you say [ICODE]s = (a + b + c)/2;[/ICODE], it's [ICODE]integer = integer / integer[/ICODE]. …
The End.
uskok