Contents:
have you tried printing inside the loop to check the value of c during each iteration?
what do you think scanf does?
and what input is it taking?
in a char I guess?
have you tried printing inside the loop to check the value of c during each iteration?
what do you think scanf does?
and what input is it taking?
in a char I guess?
princegaut 2022-09-21 18:30:13
c is char, and nc is int
princegaut 2022-09-21 18:30:17
that is working
smol_mazunki 2022-09-21 18:30:20
char just means a byte
smol_mazunki 2022-09-21 18:30:30
aka uint8_t
smol_mazunki 2022-09-21 18:30:44
by default, int is uint32_t
smol_mazunki 2022-09-21 18:30:47
aka 4 bytes
smol_mazunki 2022-09-21 18:30:51
on modern machines, that is
smol_mazunki 2022-09-21 18:32:34
have you tried printing inside the loop to check the value of c during each iteration?
princegaut 2022-09-21 18:44:19
smol_mazunki 2022-09-21 18:32:34
have you tried printing inside the loop to check the value of c during each iteration?
Yes I did
smol_mazunki 2022-09-21 18:44:26
princegaut 2022-09-21 18:44:19
Yes I did
and what did you see
princegaut 2022-09-21 18:44:30
but now my program works
princegaut 2022-09-21 18:44:34
I dont know why
princegaut 2022-09-21 18:44:37
but it works
princegaut 2022-09-21 18:44:40
here is the code
smol_mazunki 2022-09-21 18:44:41
princegaut 2022-09-21 18:44:34
I dont know why
that’s not good
princegaut 2022-09-21 18:45:04

smol_mazunki 2022-09-21 18:45:49
wait i just realized your c is an integer, not an array
smol_mazunki 2022-09-21 18:46:09
scanf(“%d”, &c); what do you think this line does ?
smol_mazunki 2022-09-21 18:47:06
princegaut 2022-09-21 18:45:04

mind the indentation here
princegaut 2022-09-21 18:49:06
princegaut 2022-09-21 18:45:04

now its a char
princegaut 2022-09-21 18:49:16
c is a char
smol_mazunki 2022-09-21 18:49:51
princegaut 2022-09-21 18:49:06

now its a char
i mean sure
smol_mazunki 2022-09-21 18:49:58
but why isn’t it an array of chars
princegaut 2022-09-21 18:50:23
Idk
smol_mazunki 2022-09-21 18:50:25
what do you think scanf does?
princegaut 2022-09-21 18:50:45
smol_mazunki 2022-09-21 18:50:25

what do you think scanf does?
it takes the input from the user
smol_mazunki 2022-09-21 18:51:18
princegaut 2022-09-21 18:50:45

it takes the input from the user
and what input is it taking?
princegaut 2022-09-21 18:51:33
in a char I guess?
princegaut 2022-09-21 18:51:42
I changed it to %c
princegaut 2022-09-21 18:51:44
now
smol_mazunki 2022-09-21 18:51:45
aren’t you passing in a document or string?
smol_mazunki 2022-09-21 18:52:03
princegaut 2022-09-21 18:51:42

I changed it to %c
meaning you are taking a single character from the user
smol_mazunki 2022-09-21 18:52:17
and assigning it to the address of c
princegaut 2022-09-21 18:52:40
why the code works then
smol_mazunki 2022-09-21 18:52:46
princegaut 2022-09-21 18:52:40

why the code works then
ask gdb