-3
#include <studio.h>
int main(void) {
     printf("Watch, Where, You, Walking!\n");
     return 0;
}

This is the code I wrote, and here is the error message that I got:

C:\Users\exoar\OneDrive\Computer\collect2.exe [Error] ld returned 1 exit status

  • 1
    How are you compiling your C code? – Abra Oct 15 '22 at 09:10
  • 4
    `stdio.h` not `studio.h`, although why that leads to a linker error is a bit odd. – Paul Hankin Oct 15 '22 at 09:10
  • Just to add a bit of context, 'stdio' is not abbreviated 'studio', it’s abbreviated 'standard in and out', or 'standard io', this 'stdio'. – S3DEV Oct 15 '22 at 09:16
  • 1
    @S3DEV more like "standard input/output" – Aykhan Hagverdili Oct 15 '22 at 09:17
  • @PaulHankin I am guessing OP has created 'studio.h' somewhere in the same directory, and because this is C the usage of `printf` is also a declaration - so it compiles. Now linker is looking for `int printf(char const*)`, which is the wrong signature so it fails. – Aykhan Hagverdili Oct 15 '22 at 09:19
  • @AyxanHaqverdili: Creating a file `studio.h` in the same directory would only cause the compiling (in contrast to linking) to work if `#include "studio.h"` had been used (see: [What is the difference between #include and #include "filename"?](https://stackoverflow.com/q/21593/12149471)) However, OP claims to be using `#include `. Therefore, I suspect that OP has **not** provided us with their actual code. – Andreas Wenzel Oct 15 '22 at 09:26
  • For the reasons stated in my previous comment, I suspect that you are not showing us your actual code. The line `#include ` has a typo, it should be `#include `. Did you have this typo in your actual code? Please always ensure that the posted code actually reproduces the problem, by testing it beforehand and then using copy&paste. – Andreas Wenzel Oct 15 '22 at 09:31
  • @AndreasWenzel That is completely implementation dependent, it is possible that they both do the same. Also most implementations let you add headers to the search path anyway. – Aykhan Hagverdili Oct 15 '22 at 10:02

1 Answers1

3

You have a spelling error in the first line:

#include <stdio.h> // this is the correct include-statement

Edit: This is probably not the solution to the problem. Nonetheless this is a further problem of the code.

  • 1
    I doubt that this is the reason for the error message that OP is getting. The typo you mentioned would cause a compilation error, however OP posted a linker error. Therefore, I rather suspect that OP is not showing us their actual code. – Andreas Wenzel Oct 15 '22 at 09:29
  • @AndreasWenzel yeah you might be right... I just tried it myself and it seems to compile with a "not found" error for the library – Matthias Thalmann Oct 15 '22 at 09:33