我想读取数据:示例文本 opp 我看到了:示例(输入)文本(输入) opp(输入)
但是,我的代码不能正常工作。
#include <stdio.h>
#include <stdlib.h>
int main(){
char separator[] = " ";
char *schowek;
char *wejscie;
gets(&wejscie);
schowek = strtok(&wejscie,separator);
while( schowek != NULL )
{
printf( "%s\n", schowek );
schowek = strtok( NULL, separator );
}
return 0;
}
好的,我有这个代码。
#include <stdio.h>
#include <stdlib.h>
int main()
{
char * slowo[] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten",
"eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen",
"twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety", "hundred",
"thousand", "million"};
int liczba[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,30,40,50,60,70,80,90,100,1000,1000000};
char n[]="";
int i=0;
char s1[]="zero";
char separator[] = " ";
char wejscie[1024];
if (fgets(wejscie, 1024, stdin))
{
char* schowek = strtok(wejscie,separator); /* Removed '&'. */
if(strcmp(wejscie,n)==0)
{
exit;
}
while (schowek)
{
printf("%s\n", schowek);
schowek = strtok(NULL, separator);
}
}
return 0;
}
他一切都好吗?现在我想将字符串转换为数字。
样本输入
六负七百二十九一百万一百一
样本输出
6 -729 1000101
我怎样才能做到这一点?