Problem with C programming


#1

Hey everyone,!
I just downloaded Atom and I’m not a super advanced user and programmer(
the problem is that I can’t use the “scanf” (so the program doesn’t show anything when there’s “scanf” in the code )
Help Please (And Sorry for my English ) :innocent:


#2

You’ll have to be a little more specific as to what the problem is. Can you include steps to reproduce the problem or record a GIF that shows the issue?


#3

There’s a simple code that I’m trying to run

#include <stdio.h>
main()
{
int a, b, c;
scanf ("%d%d", &a, &b);
c=a+b;
printf("%d+%d = %d \n", a, b, c);
return 0;
}

So when I’m trying to run it,it just shows only a warning
"Type specifier missing,defaults to ‘int’ [-Wimplicit-int] main ()"
And then nothing :frowning:
Sorry ,but I can’t do the gif
And I’m using a Macbook (maybe this info is useful somehow)


#4

This seems a basic C syntax error, nothing to do with Atom… Anyway, the problem is that you didn’t specify a type for function main: this is the corrected code

#include <stdio.h>
int main()
{
  int a, b, c;
  scanf ("%d%d", &a, &b);
  c = a + b;
  printf("%d+%d = %d \n", a, b, c);
  return 0;
}

#5

Oh thanks!) but I still can’t input a and b :frowning:
Looks more complicated than in Xcode
Anyway,I still want to learn how to work in atom
:smile:


#6

Atom, by its nature, is a text editor. It doesn’t compile C code out of the box. If you’ve added a package that does this, please specify which package you’re using.


#7

I use “Script” package


#8

I’m pretty sure that the Script package doesn’t let you run anything interactively, so it’s not going to let you input anything while it runs.