[Courses] [C] Beginner's Lesson 4A: Arrays, Qualifiers,
and Reading Numbers
Morgon Kanter
admin at surgo.net
Thu Oct 10 17:59:53 EST 2002
Hey, its me again. This is just some various stuff I wanted to say.
First of all, could you please, in the next part of the lesson, include a
list of what each of the functions in the standard C library does? I want
to print something like this out to have on hand, but you only list a
couple each lesson! =)
The first thing I had to say:
Hey, I tried this out without the .0s at the end of the numbers and it
worked exactly the same. Why are you including .0s for the floats? I know
you have to do this in Java, but not here it seems. What I'm talking about
is when you wrote:
data[0] = 34.0;
data[1] = 27.0;
data[2] = 45.0;
data[3] = 82.0;
data[4] = 22.0;
Why not:
data[0] = 34;
data[1] = 27;
data[2] = 45;
data[3] = 82;
data[4] = 22;
And the second:
Just a small detail excluded I guess, but after putting:
strcpy(full, first);
strcat(full, " ");
strcat(full, last);
Why don't you ask what happens if you put:
strcat(full, " ", last);
a compile time error (too many parameters), of course. But it would be a
good idea to add that I guess. Too bad you can only concatenate one thing
at a time. This is where a concatenation operator would have been nice =)
The third:
When you do:
printf("Enter a line: ");
fgets(line, sizeof(line), stdin);
printf("The length of the line is: %d\n", strlen(line));
You can do
printf("The length of the line is: %d\n", strlen(line) - 1);
to get the true size of the line, not with the \0 at the end.
And lastly:
Please explain _format_, sscanf, and all that! I'm confused there.
More information about the Courses
mailing list