0

Hi,

I have global and local variable with same name, and I would like to access global variable.

But I am getting this error: "error: syntax error before ':' token" .
I have GCC 3.4.6 on CentOS 4.7

#include <stdio.h>

int amount=20;
int main()
{
    int amount=10;
    int k = ::amount;
    printf("%d\n", k);
    return 0;
}

Thanks & Regards,
Prakash Joshi
:) :) :)

Edited by Reverend Jim: Fixed formatting

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Ancient Dragon
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.