I want to read the data: sample text opp I see this: sample (enter) text (enter) opp (enter)
However, my code does not work well.
#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;
}
Ok, I have this code.
#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;
}
Is everything alright with him? Now I want to convert string to number.
Sample Input
six negative seven hundred twenty nine one million one hundred one
Sample Output
6 -729 1000101
How can I do that?