1

I am learning C programming from CS50. I was trying to to build parity program. Here is my code,

# include <cs50.h>
# include <stdio.h>

int main (void)
{
    int n=get_int("n: ");
    if(n%2==0)
    printf("even\n");
    else
    printf("odd\n");
}

when I try to compile I get the following error,

clang: error: linker command failed with exit code 1 

Can anyone tell what's going on here?

I was trying to compile this on official CS50 IDE and I got that error .

This is my first question on stackoverflow, so pardon me if I am doing any bad formatting or styling.

Any help will be highly appreciated.

Chumki Haldar
  • 31
  • 1
  • 4
  • That error message is only the summary. The relevant messages are shown before that line. I would assume the linker complains about missing `get_int`. Do you link `cs50` library? How do you build your project? – Gerhardh Mar 22 '22 at 18:35
  • @Gerhardh I do not know much about it I'm a beginner . I have no prior programming experience. I am doing this on CS50 online IDE which is an ubuntu system . – Chumki Haldar Mar 22 '22 at 18:44
  • Does this answer your question? [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Stephen Newell Mar 22 '22 at 18:52

1 Answers1

2

I figured it myself. There was a folder with same name as my c source file. That's why clang got confused.

Chumki Haldar
  • 31
  • 1
  • 4