0
#include <stdio.h>
int main(){
    char a[5];
    for(char i = 0, i < 5, ++i){
        scanf("%c", &a[i]);
    }
    printf("%c", a[5]);
return 0;
}

I changed a[5] into a[i] in the printf, nothing changed. I have compared with this one i found on the net(which works ofc):

int main() {
  int values[5];
  for(int i = 0; i < 5; ++i) {
     scanf("%d", &values[i]);
  }
  for(int i = 0; i < 5; ++i) {
     printf("%d\n", values[i]);
  }
  return 0;
}

1 Answers1

1

You are using , instead of semi colon ; in the for loop.

for(char i = 0, i < 5, ++i)

Correct Usage:

for(char i = 0; i < 5; ++i)

stud3nt
  • 2,056
  • 1
  • 12
  • 21
  • 1
    Wow, i haven't even noticed that! :o do i feel dumb now. Thank you very much! i wanna read one side of an equation so i need to be able to read both letters and numbers, so afaik i cannot use int. Edit: int inside the for loop, i gotchu. – Lord Commander Dec 04 '19 at 15:48
  • Sure, I'll edit the answer. Please upvote and mark it as answer, it it has helped you. Welcome to Stackoverflow! – stud3nt Dec 04 '19 at 15:53
  • i dont have enough rep but i will try! ^^ – Lord Commander Dec 04 '19 at 15:54
  • Reps aren't required for upvoting, asking questions or marking answers. – stud3nt Dec 04 '19 at 15:55