Christopher Pettit
Christopher Pettit

Reputation: 35

Too few arguments to function call

I am new to C programming and working through a book called " Sam's Teach Yourself C Programming in One Hour A Day"

One of the Exercise programs in chapter 2 is giving me an error I am too novice to understand. A little help and clear explanation without pompous sarcasm would be much obliged! Thank you for your time and consideration.

Exercise Program

Upvotes: 1

Views: 6688

Answers (1)

Bijay Gurung
Bijay Gurung

Reputation: 1104

The error says it all: fgets() expects three arguments. You are giving it one.

So, call it like this:

fgets(buffer, 256, stdin)

buffer is where the input is to be stored, 256 is the size of the buffer, stdin is the stream to read from.

Also, use %lu instead of %d as the format specifier for unsigned long.

Edit: Use the z modifier as %zu for the value returned by strlen, which is of type size_t

Upvotes: 1

Related Questions