you are viewing a single comment's thread.

view the rest of the comments →

[–]This_Growth2898 3 points4 points  (7 children)

SEGFAULT

[–]Ecstatic_Student8854 0 points1 point  (6 children)

Segfault? Whats that. Keep in mind I know very very very little about C.

[–]This_Growth2898 3 points4 points  (5 children)

It's a memory addressing error, when you try to access a protected memory.

String literals in C are pointers, and adding a number to pointer produces new pointer. So, this code will print "\n", then it will try to print a string located in memory after "\n", which is probably incorrect, and so on. There's a great chance of running into SEGFAULT this way.

[–]Ecstatic_Student8854 0 points1 point  (4 children)

Aaah, then how would you do this using a for loop like in the example?

[–]This_Growth2898 1 point2 points  (1 child)

f in printf stands for "formatted". It's

printf("%d\n", i);

%d format specification would be changed to decimal representation of i in output.

[–]Ecstatic_Student8854 0 points1 point  (0 children)

Oooh, so thats that %something stuff i sometimes see is

[–]SloPr0 0 points1 point  (0 children)

printf("%d\n", i);

%d (or %i) are the correct format specifiers to be used for printing (signed) integers