1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | @Luchian Grigore I'm using this code your provided but I want to change "Guy" into a const varaible. Can you please help me understand what the different between the following implementation ( all work fine) : char * const AUTHOR_NAME = "GUY"; static char * AUTHOR_NAME = "GUY"; char * AUTHOR_NAME = "GUY"; All these are above the main. For some reason the following line didn't work for me : char * const AUTHOR_NAME = "GUY"; Thaks, Guy |
QEx1Y2hpYW4gR3JpZ29yZSBJJ20gdXNpbmcgdGhpcyBjb2RlIHlvdXIgcHJvdmlkZWQgYnV0IEkgd2FudCB0byBjaGFuZ2UgIkd1eSIgaW50byBhIGNvbnN0IHZhcmFpYmxlLgoKQ2FuIHlvdSBwbGVhc2UgaGVscCBtZSB1bmRlcnN0YW5kIHdoYXQgdGhlIGRpZmZlcmVudCBiZXR3ZWVuIHRoZSBmb2xsb3dpbmcgaW1wbGVtZW50YXRpb24gKCBhbGwgd29yayBmaW5lKSA6CgogICAgY2hhciAqIGNvbnN0IEFVVEhPUl9OQU1FID0gIkdVWSI7CgogICAgc3RhdGljIGNoYXIgKiBBVVRIT1JfTkFNRSA9ICJHVVkiOwoKICAgIGNoYXIgKiBBVVRIT1JfTkFNRSA9ICJHVVkiOwoKCkFsbCB0aGVzZSBhcmUgYWJvdmUgdGhlIG1haW4uCgpGb3Igc29tZSByZWFzb24gdGhlIGZvbGxvd2luZyBsaW5lIGRpZG4ndCB3b3JrIGZvciBtZSA6IAoKICAgIGNoYXIgKiBjb25zdCBBVVRIT1JfTkFNRSA9ICJHVVkiOwoKVGhha3MsCkd1eQoKCg==
prog.cpp:1: error: stray ‘@’ in program prog.cpp:1:19: warning: missing terminating ' character prog.cpp:1: error: missing terminating ' character prog.cpp:14:40: warning: missing terminating ' character prog.cpp:14: error: missing terminating ' character prog.cpp:1: error: ‘Luchian’ does not name a type prog.cpp:7: warning: deprecated conversion from string constant to ‘char*’ prog.cpp:9: error: redefinition of ‘char* AUTHOR_NAME’ prog.cpp:7: error: ‘char* AUTHOR_NAME’ previously defined here prog.cpp:12: error: ‘All’ does not name a type prog.cpp:18: error: expected constructor, destructor, or type conversion before ‘,’ token prog.cpp:19: error: expected constructor, destructor, or type conversion at end of input prog.cpp:7: warning: ‘AUTHOR_NAME’ defined but not used
-
result: Compilation error (maybe you wish to see an example for C++ 4.7.2)


