2
votes
Accepted
Recover PSET 4 Week 4 - skipping while loop
First of all, are you sure that you remembered to recompile/make a new executable from the new source code file? The while loops are working fine.
When I test the code, it's generating the correct ...
2
votes
Accepted
PSET6 Load - How To Approach? Also, Is It Better To Use While() Loop or For() Loop?
Q1. Should I use fgetc() or fread()
A1.: You can make both work! Choose the one you're more comfortable with.
Q2. I don't know whether to use a for loop or a while loop. Is one better for this ...
2
votes
Accepted
pset2 Crack - Looping through fgets
Let's take a look at the man page of strcat():
char *strcat(char *dest, const char *src);
The strcat() function appends the src string to the dest
string, overwriting the terminating null ...
2
votes
Accepted
while loop executes randomly
The while loop is not random. The sort function doesn't handle duplicates (ie values[i] == values[i + 1]) so the while loop goes "infinite" because if( sortcount == (n - 1) ) is never true. I suspect ...
1
vote
Accepted
PSet1 While Loop to Print Spaces for Mario Not Working
For the first inner loop, use a while loop, not do..while, as you don't want any space printed in front on the last line.
The difference between while and do..while is that the do..while runs at ...
1
vote
Accepted
What is the problem with my get_int for the lab 1 question population in C?
That program will end if a value greater than 8 is entered for x. The return x; returns from the main function, which is to say program ends. Ditto the return y;. return is the statement that ends a ...
1
vote
While loop for recover pset4
Fread() function allows you to iterate over file if combining with the while loop.
Basically the fread() function will look at the file and search for a block size of 1 byte 512 times or similarly you ...
1
vote
Accepted
Pset1 Cash Understanding modulo operator and while loops
You have created an infinite loop. If the loop starts, it will never exit the loop. It tests the value contained in amount to decide to continue or exit, but since the value of amount is not changed ...
1
vote
Stumped on pset1 cash.c, please help me learn
More accurately, it isn't counting pennies correctly. In fact, it isn't counting a lot of things correctly. (Try $4.20) The cause of the problem is the whole purpose of this pset. Because of that, I'...
Only top scored, non community-wiki answers of a minimum length are eligible