Nitish Nitish -3 years ago 143
C Question

Input/ Output alternatives for printf/scanf

It may sound strange that knowing a lot about iOS and having some experience in .net, I am a newcomer to C. Somewhere I got this target to find average of n numbers without using

. I don't want the code for the program but it will be really helpful if someone can help me with the alternatives to the mentioned functions.

Please let me know if code with
is required here. Also do let me know if my query stands invalid.

Answer Source

No, neither printf nor scanf is really needed for this.

The obvious alternatives would be to read the input with something like getc or fgets and convert from characters to numbers with something like strtol.

On the output side, you'd more or less reverse that, converting from numbers to characters (e.g., with itoa which is quite common, though not actually standard), then printing out the resulting string (e.g., with fputs).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download