Ask coding questions

← Back to all posts
why the code somethimes broke
s1f2z3 (0)

same code but sometimes just don't want to do the loop plz if anyone know why tell me

Comments
hotnewtop
Coder100 (17038)

scanf is not the greatest at getting user input, you should use this method instead:

char str[1024];
getline(str, 1024, stdin);

char T[200];
sscanf(str, "%s", T);

easy!

s1f2z3 (0)

@Coder100 I don't think the mistake in it , cause it work but the second "for" sometimes just skip for no reason.
and isn't "fgets" better than "getline" ?

Coder100 (17038)

@s1f2z3 i think fgets should be the same result as getline, I have seen both being used.
anyways I'll look

s1f2z3 (0)

@Coder100 oh thank u , and i want to ask why the code just skip the second loop sometimes ?

Coder100 (17038)

maybe because you started at 1 and the tail is 1? @s1f2z3

s1f2z3 (0)

@Coder100 i really don't know sometimes work and sometimes don't like i send the problem is i give it the same input

Coder100 (17038)

@s1f2z3 yeah seems like you need to fix your multiplication

s1f2z3 (0)

@Coder100 multiplication ? do u mean "j=j*numbers[i]" ?
if yes , why ? i didn't see anything wrong in it

Coder100 (17038)

@s1f2z3 hm
try printing the value of the number that is being multiplied by, some data is being corrupted there.

s1f2z3 (0)

@Coder100 i think i find the mistake but it was when i put "char" in the mid not the begine , so i find it i think it work well thank u dude