Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char *a;
- void function()
- {
- if(a == NULL)
- {
- a = "Test1";
- }
- else
- {
- a = "Test2";
- }
- }
- #include <stdlib.h>
- #include <stdio.h>
- char *a;
- void function();
- int main( int argc, const char *argv[] )
- {
- function();
- function();
- function();
- function();
- return 0;
- }
- void function()
- {
- printf( "function: a=%s", (a ? a : "NULL") );
- if(a == NULL)
- {
- a = "Test1";
- }
- else
- {
- a = "Test2";
- }
- printf( " exiting a=%sn", (a ? a : "NULL") );
- }
- This produces the following output:
- function: a=NULL exiting a=Test1
- function: a=Test1 exiting a=Test2
- function: a=Test2 exiting a=Test2
- function: a=Test2 exiting a=Test2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement