0

No Numerals (C language)

I am unable to complete this code although I have tried some methods but didn't work out for me So, please if anyone whose expertise is in C Please help me out I would be very thankful to you. Here, the code #include <stdio.h> #include <string.h> int main() { char num[10]= {"0123456789"}; char words[10][50]={"zero","one","two","three","four","five","six","seven","eight","nine"}; char string[40]; fgets(string,40,stdin); for(int i=0; i<strlen(string); i++){ for(int j=0; j<strlen(num); j++){ if(string[i]==num[j]) { } } } return 0; }

13th Mar 2021, 3:50 PM
Vishal
Vishal - avatar
5 odpowiedzi
+ 1
You don't need really replace in this task, you can print it. Print textual part, print word or number, print next textual part.. .
16th Mar 2021, 6:23 AM
Igor Kostrikin
Igor Kostrikin - avatar
0
You could use isdigit() function to detect numbers
13th Mar 2021, 5:47 PM
Igor Kostrikin
Igor Kostrikin - avatar
0
I don't know know what to do after detecting number I think detecting a number is already in the code in if condition
13th Mar 2021, 8:15 PM
Vishal
Vishal - avatar
0
according to the conditions of the task, it is necessary to replace all numbers from 0 to 10 with words. firstly, you forgot 10. secondly, the replacement should not occur for any numbers starting from 11 and more. one of the options is to split the original string into words and check them for coincidence with numbers.
15th Mar 2021, 12:01 PM
Igor Kostrikin
Igor Kostrikin - avatar
0
That's the point I don't know how to replace the num with word cause if I try to assign it. It wil definitely show that you cannot assign "one" word at "1" position How can I do that's what I am trying to ask
15th Mar 2021, 7:50 PM
Vishal
Vishal - avatar