in Compiler Design
5,234 views
1 vote
1 vote
Find no of tokens in below program.

#include<stdio.h>

main()

{

   int I;

   int *pi = &I; //parent pointer

   scanf("%d",pi);

   printf("%d\n", I+5);

}
in Compiler Design
by
5.2k views

4 Comments

i am getting total num of tokens as 32
0
0

References to printf and scanf are actually resolved by the linker by providing the object code for printf and scanf and other library functions.

In the preprocessing phase only function prototype are included in source code .

So the actual resolving done by linker .

That linking again of two types--

   Static linking 

   Dynamic linking

0
0
Total number of tokens are 31
0
0

1 Answer

1 vote
1 vote
statement # of tokens
#include<stdio.h> 0(zero)
main() 3
{ 1
   int I; 3
   int *pi = &I; //parent pointer 7
 scanf("%d",pi); 7
   printf("%d\n", I+5); 9
} 1
Total 31

1 comment

@sudharshan We can't say that 

#include<stdio.h>	

will have 0 tokens because in the preprocessor stage this header would be expanded to its actual content.

And the number of tokens would be huge !!!

0
0