Hi. How to find index of first letter in every word in a string?
For example, input string is: Programming Languages. Output should be: 0 12, those are the indexes of letters "P" and "L".
I tried different approach, to print those numbers but that didn work. Thanks for the answers.
Code:
#include<stdio.h>
#include<string.h>
int main()
{
char str[100];int i;int n=strlen(str);
printf("enter a string:\n");
gets(str);
for(i=0;i<n;i++)
{
if(str[i]==' ')
{
printf("%c",str[i+1]);
}
else
printf("%c",str[i]);
}
return 0;
}