![]() |
help wid a programme
Code:
#include<stdio.h>wat i m trying to make is tat :- this function will count the characters used and tell me in decimal format. the main reason for making this function is that it will help in malloc(); function to allocate exact memory.... plzzzzzz help................. and wen i am putting a space the loop terminates... and shows only first charcters eg:- if written:- aneesh hi output:- 6 characters... help!!!!!!!!!!!!! |
Re: help wid a programme
scanf is not suitable for this task
it stops when it sees a space or enter use gets or fgets for the count problem there is a command--->strlen Code:
#include<stdio.h> |
Re: help wid a programme
Code:
#include<stdio.h> |
Re: help wid a programme
fgets is better than gets because it specifies a maximum count and won't overflow the buffer. Use stdin for the file pointer. If the string ends with \n then that is all the user entered; if not, there is more and another call to fgets will pick up the next lot of characters.
|
| All times are GMT +5.5. The time now is 13:08. |