Reedwan Nouman
Reedwan Nouman

Reputation: 57

How to fix ---->warning: extra tokens at end of #include directive

When I try to run this code

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

it cannot compile and shows this message bellow

main.c:1:19: warning: extra tokens at end of #include directive [enabled by default]

Upvotes: 0

Views: 6073

Answers (2)

Alejandro Caro
Alejandro Caro

Reputation: 1082

Directives must be separate and one below the other. On the other hand, in this code the variable i is unnecessary.

#include<stdio.h>

int main(){  
    int a,b;  
    scanf("%d %d", &a, &b);     
    printf("sum is %d\n", a+b);     
    return 0; 
}

Upvotes: 1

Evan VanderZee
Evan VanderZee

Reputation: 867

Your #include directive should have a space after it, and int main() should be on a separate line from the include directive.

Upvotes: 0

Related Questions