#include<stdio.h>
#include<string.h>
main()
{
char a[300];
int i;
printf("please input:\n");
for (i=0; ; i++)
{
scanf("%c", &a[i]);
if (a[i] == '\n')
break;
}
printf("the numbers of string is: %d", i);
getch();
}
稍微改了下,现在空格也算了,应该没问题吧
#include<string.h>
main()
{
char a[300];
int i;
printf("please input:\n");
for (i=0; ; i++)
{
scanf("%c", &a[i]);
if (a[i] == '\n')
break;
}
printf("the numbers of string is: %d", i);
getch();
}
稍微改了下,现在空格也算了,应该没问题吧