Table of contents
What is the Difference Between putw and puts function in c?
puts in c function is used to write a string to stout. Whereas putw function is used to write an integer value into a file.
Putw requires a pointer to file but puts don’t require a pointer.
putw returns zero on successful operation otherwise non-zero value is returned. puts returns a non-negative value on completion otherwise EOF is returned.
Prototypes are as follows:
int puts(const char *strng);
int putw(int w,FILE *strm);
Easily remember all differences using the table below:
putw in c | puts in c |
Used to write an integer value into a file. | Used to write a string to stout. |
Returns zero on successful operation otherwise non-zero value is returned. | Returns a non-negative value on completion otherwise, EOF is returned. |
int putw(int w,FILE *strm); | int puts(const char *strng); |