Difference between static global and global?

Answers were Sorted based on User's Feedback



Difference between static global and global?..

Answer / mukesh

global variable is accessed in all file by use extern keyword.while static global only visible in file in which it is declared.

Is This Answer Correct ?    0 Yes 0 No

Difference between static global and global?..

Answer / nischal bansal

Static global variable can be used only in the file, it is
declared whereas global variable can be used in other files
also. we have to include the file, in which we have
declared the variable

Is This Answer Correct ?    2 Yes 3 No

Difference between static global and global?..

Answer / sheela

hello...

what r all above said is false. global static also can
access using extern in other files.

file 1:

#include<stdio.h>
#include <conio.h>
#include "file2.c"
int a=10;
static int b=20;
main()
{
send();
}


file 2:


#include<stdio.h>
#include<conio.h>

void send()
{
extern int a;
extern int b;
printf("%d%d",a,b);
getch();
}


this program prints both a and b values.. then how can u
say global statics has file scope.

please if anybody knows correct answer give me.

Is This Answer Correct ?    0 Yes 1 No

Difference between static global and global?..

Answer / chitra

static global is fixed.but global variables are changed.

Is This Answer Correct ?    7 Yes 88 No

Difference between static global and global?..

Answer / afroz

there is no any diffrence between static and non static
global variable

Is This Answer Correct ?    16 Yes 115 No

Difference between static global and global?..

Answer / priya

static means fixed we should not change anything,but in non
static we can change.

Is This Answer Correct ?    5 Yes 106 No

Post New Answer

More C++ General Interview Questions

Read the following program carefully and write the output of the program. Explain each line of code according to given numbering. #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <errno.h> 1……………… int main (void) { pid_t pid; 2………………………… pid = fork(); 3…………………………. if (pid > 0) { int i; 4………………………… for (i = 0; i < 5; i++) { 5………………… …………… printf(" I AM VU : %d\n", i); 6………………… …………… sleep(1); } exit(0); } 7………………… ……… else if (pid == 0) { int j; for (j = 0; j < 5; j++) { 8……………………………… printf(" I have no child: %d\n", j); sleep(1); } _exit(0); } else { 9………………………………fprintf(stderr, "can't fork, error %d\n", errno); 10……………… … ………… exit (EXIT_FAILURE); } }

1 Answers  


What's the best free c++ profiler for windows?

0 Answers  


What are abstract data types in c++?

0 Answers  


What are activex and ole?

0 Answers  


Who discovered c++?

0 Answers  






Can c++ be faster than c?

0 Answers  


What is a rooted hierarchy?

0 Answers  


Which is the best c++ compiler?

0 Answers  


Why pure virtual functions are used if they don't have implementation / When does a pure virtual function become useful?

1 Answers  


Can we make any program in c++ without using any header file and what is the shortest program in c++.

0 Answers   MCN Solutions,


Is c better than c++?

0 Answers  


What is private, public and protected inheritance?

0 Answers  


Categories