Wow...So in this case the use of feof() did cause the error! By removing the extra return character at the end it solved the problem of the extra "0" at the end.
Type: Posts; User: DuckCowMooQuack
Wow...So in this case the use of feof() did cause the error! By removing the extra return character at the end it solved the problem of the extra "0" at the end.
Hey guys and gals,
Below is my code, my input file, and the output. I can't figure out why it is adding an extra zero at the end though. Can anyone help me with this?
CODE:
#include...
I know that's bad. That's not where the seg fault is happening though. I'm not focused on proper practice of feof(). Thank you for the useful info though! :D
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
FILE *ofp;
BTW: Thanks to everyone who continued to monkey with this and try for fixes. Thanks a ton!
-DCMQ
Happy coding!
Ok I solved it. All I did was delete the semi colon after
while (x > 40);
compiled it...
added the semi colon back
compiled it
ran it...It now works
Here's my complete code as of now...
#include<stdio.h>
int main(void)
{
int x = 0;
I am executing the program from within Cygwin terminal. I edit the code from within Notepad++, save it, compile it, and then run it.
This is part of a larger program. I'm just trying to get this to work.
It's still not picking up on the printf("%d",x);
I have no idea why???
It's odd it's not reading that for me. I'll keep messing with it I guess. Thanks the the fast reply though laserlight!
Ok so if you look at line 27 I am calling it to print "x" to the screen. What it should do is print whatever number was last entered by the user. (The loop makes sure this number is less than 40).
...
Hello everyone,
In the code below why is it not grabbing a value for x?
#include<stdio.h>
int main(void)
How would I convert this iterative function to recursive? (link2 h) is the list.
void printlist (link2 h)
{
link2 head = h;
link move;
int x;
move = head->front;
Ha-ha, Just listen to Jim...
No problem...Quite honestly, the knoledge of knowing how to score a bowling game could be the difference between life and death! I wouldn't want anyone to die :D
Why not just use integers instead a bunch of arrays...
like:
int t1, t2, t3, t4, t5, t6;
double t7, t8, t9, t10;
This will solve your printing problem. Right now when you print, you are...
How to score a game of Bowling...How to Score a Game of Bowling - Bowling Scoring
Listen to CommonTater...In every math class I've taken Range means difference in the highest and lowest value. Example: 1, 2, 7, 9 Highest = 9 Lowest = 1 Range = 8
With any modern day computer...Unless you have like thousands of lines of comparison statements...it won't matter too much. What is the actual program you are implementing the switch statement in?
Thanks quzah and kmess!
-Duck
The switch statment in this case is more efficient. Sometimes it's a decision of how elegent you want your code to look, or how elegent you want to solve a problem.
#include<unistd.h>
usleep(amount of time to wait);
Place usleep(); after any part you want to pause.
Example:
#include<stdio.h>
Here's some code I wrote...Use it for reference.
#include <stdio.h>
#include <stdlib.h>
int main()
{
Hey everyone,
Does anyone have any good examples, tutorials, resources on recursion? It's a new topic i've started and I'm having trouble finding good info on it.
Thanks,
!--||\/ Duck \/||--!