Here is the code i have written to accept string from the user.
Can you please modify the code so as it can even count the space as well as print the whole line with the spaces instead of the first word.
Thanks a lot.
#include <stdio.h>
#include <assert.h>
#include <malloc.h>
#include <conio.h>
int strlength (char input[])
{
int count = 0;
while (input[count++] != '\0');
return count;
}
main ( )
{
char* s = 0;
char inputBuffer;
int index = 0;
printf("\nEnter the name u want to enter : ");
while ((inputBuffer = getchar()) != '#') // some termintaing cond.
{
s = malloc(sizeof(char));
s[index] = inputBuffer;
}
printf("The length of this string is %d", strlength(s));
printf("\n");
}