0

greedy.c:8:7: note: previous definition is here int i;

This variable has been declared and used and I am getting this error message.

If I remove the declared variable then it tells me I didn't declare it. So then I re-add variable then it gives me this error.

5
  • 1
    Error like this usually means you redeclared variable in the same (or lower) scope. Please share entire error log or part of the code which doesn't work as expected (or both), since now I can't be sure that's real source of the trouble. Commented Jul 24, 2015 at 16:38
  • Can you post every line that has this i variable on it?
    – i_am_david
    Commented Jul 24, 2015 at 20:26
  • jharvard@appliance (~/Dropbox/pset1): make greedy clang -ggdb3 -O0 -std=c99 -Wall -Werror greedy.c -lcs50 -lm -o greedy greedy.c:7:1: error: expected identifier or '(' do ^ greedy.c:11:2: error: expected identifier or '(' while ^ 2 errors generated. Commented Jul 25, 2015 at 1:30
  • I get this error message for this code: #include <stdio.h> #include <cs50.h> #include <math.h> int main (void); do printf("Please give me the amount of change owed.\n") int money = Getint (); while ( money > 0) Commented Jul 25, 2015 at 1:31
  • if I add curly braces it tells me they are wrong. I am thinking there is something wrong with my appliance. Please let me know what you think. Commented Jul 25, 2015 at 1:32

1 Answer 1

0

You need a semi colon after the printf statement within the do loop. Would need to see more of the code to determine whether anything else may be missing.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .