Hi
I haven't posted here very often cause I tend to find the answers I'm looking for in other peoples posts and in the FAQs. So I hope you don't mind me highlighting this news item which some of you...
Type: Posts; User: Hobo
Hi
I haven't posted here very often cause I tend to find the answers I'm looking for in other peoples posts and in the FAQs. So I hope you don't mind me highlighting this news item which some of you...
Just thought you might like to know your scanf should be
scanf("%d%d%d", &first_number, &second_number, &third_number);
hobo
My head is definitly on backwards today, I didn't notice the jump in line numbers so disregard previous answer but you might want to post more code.
33: if ( fptr == NULL ) {
34- printf ( "Unable to open \"%s\" to write.\n", argv[3] );
--
155- fprintf ( stdout, "%d\t%d\t%d\n", i+1, j+1, adjacency[i][j] );
156: fprintf ( fptr,...
Sorry keep the inner do loop, my head must be on backwards or something.
If you have declared name as:
char name[40];
Then it can only hold 39 chars, one char is needed for '\0' at the end of the string.
Take away the inner do loop and make sure clrscr() is...
If I've got this right you want your code to keep prompting for input if the previous input was invalid. Also you want it to clear the previous input and start at the same place on the screen.
If...
I can't speak for anyone else but I do, and I usually find my answer there or by searching previous posts, hence the reason for the number of posts I have made being so small.
hobo
I haven't used it in a while but once you compile (Alt+F9) and then run (Ctrl+F9) you can view your programs screen output (if there is any) by pressing Alt+F5 and then press any key to return to the...
I take your point Prelude.
It amazes me how many things that I've been taught are either not good practice or just plain wrong and I'm obviously not the only one, going by the numerous posts that...
linuxdude wrote
You could do
while(!strcmp(str1,str2))
which would mean the loop would keep going while the strings were equal.
hobo
I get the impression the question is asking you to convert 'cups' to all three. eg
if
cups = 16
then
gallons = 1
quarts = 4
pints = 8
and then print out the value of all three. Therefore...
your call to scanf should be
scanf("%s", row);
no '&' is needed for a string.
However what is there to stop the user from entering more than the allowed chars ie 4 + '\0'. Try using fgets if...
The answer you received was intended to help but it expected a little work on your part.
Anyway, I'm not a raw beginner but I'm no expert either. So I'll only attempt to give you a short example.
...
for ( pass = 1; pass <= 3 - 1; pass++ ) /* passes */
for ( i = 0; i <= 3 - pass -1; i++ ) /* one pass */
if ( strcmp( customer[i].lastname, customer[i+1].lastname ) == 1) {
hold = customer[i];...
If you use mode "a" this defaults to a text file, the same as if you use "at". Therefore you've opened your binary file as a text file. You need to use "ab".
I'm sure this is right but someone...
>Although we will all learn C, by our selves
I understand what you mean but don't forget that if you all start off knowing nothing about C and albeit learning from each other, you should still...
I don't think it would cause a problem but I had to type:
value,value,value,value,value<enter>
without the commas I typed:
value<enter>
value<enter>
value<enter>
value<enter>
value<enter>
Thanks for your response, either way it produces the same results, but I can see why testing the return value of the read function is the better way to go.
Thanks again.
hobo
I've written a program which sorts variable sized records on a binary file
into customer number order. I'm using feof() to terminate my loops, which
works and I get the required results. I'm just...
>f=float average(a,b,c,d,e);
your function returns a float but f is a double, and you have 'float' in front of the call to the function, can you do that?
not sure about the scanf thing,
does ...