Click here to Skip to main content
15,898,722 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
Member 1014067829-May-18 1:47
Member 1014067829-May-18 1:47 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
Kirk 1038982129-May-18 1:59
Kirk 1038982129-May-18 1:59 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
nullusDefectus29-May-18 2:11
nullusDefectus29-May-18 2:11 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
Hans Salvisberg29-May-18 3:20
Hans Salvisberg29-May-18 3:20 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
ZimFromIRK29-May-18 3:34
ZimFromIRK29-May-18 3:34 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
SeattleC++29-May-18 4:32
SeattleC++29-May-18 4:32 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
Jesse Connell29-May-18 6:03
Jesse Connell29-May-18 6:03 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
jfbode102930-May-18 10:46
jfbode102930-May-18 10:46 
There are indeed pointer types, but there are no pointer type specifiers. The pointer-ness of something is specified by a combination of the type specifier(s) and the declarator. For a pointer like
C++
char *p;

the type of p is "pointer to char" or char *, but that type is obtained by the combination of the type specifier char and the pointer declarator *p. Sure, you can write it as char* p;, but it will be parsed as char (*p);.

Something like
C++
T *p1, *p2, *p3;
should be perfectly understandable to anyone who understands C and C++ declaration syntax, but nobody does because it's not taught properly for some bizarre reason. It's such a fundamental part of the language, but it's invariably glossed over in every introductory text so as not to scare off beginners. So people inevitably bluescreen the first time they see something like a pointer to an array or a pointer to a function because the simplistic-to-the-point-of-being-wrong version of C declaration syntax they were taught doesn't account for it.

Yes, pointers are scary and difficult to understand at first. They're also a fundamental part of C programming (less so C++, but still important). C (and C++) declaration syntax needs to be taught properly and completely. But since it isn't, we need to come up with a bunch of coding standards to make up for it. So, no more than one declaration per line, because it's too hard to explain how char* a, b; really works.

Once you understand the rules, pointer declarations (including pointers to arrays, pointers to functions, pointers to arrays of functions returning pointers to arrays of pointers to int) make perfect sense. But apparently nobody understands the rules, so the language looks arbitrary and capricious.
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
Jesse Connell30-May-18 17:31
Jesse Connell30-May-18 17:31 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
PNutHed29-May-18 6:05
PNutHed29-May-18 6:05 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
englebart29-May-18 11:27
professionalenglebart29-May-18 11:27 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
ClockMeister29-May-18 13:19
professionalClockMeister29-May-18 13:19 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
david garlisch29-May-18 16:59
david garlisch29-May-18 16:59 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
jfbode102930-May-18 3:58
jfbode102930-May-18 3:58 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
Chad3F30-May-18 8:53
Chad3F30-May-18 8:53 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
code_junkie31-May-18 3:52
code_junkie31-May-18 3:52 
GeneralLife back to normal Pin
lopatir25-May-18 22:52
lopatir25-May-18 22:52 
GeneralRe: Life back to normal Pin
RickZeeland26-May-18 0:17
mveRickZeeland26-May-18 0:17 
GeneralRe: Life back to normal Pin
OriginalGriff26-May-18 0:31
mveOriginalGriff26-May-18 0:31 
GeneralRe: Life back to normal Pin
RickZeeland26-May-18 0:37
mveRickZeeland26-May-18 0:37 
GeneralRe: Life back to normal Pin
OriginalGriff26-May-18 1:10
mveOriginalGriff26-May-18 1:10 
GeneralRe: Life back to normal Pin
lopatir26-May-18 2:27
lopatir26-May-18 2:27 
GeneralLow profile Pin
RickZeeland25-May-18 20:30
mveRickZeeland25-May-18 20:30 
GeneralRe: Low profile Pin
CPallini25-May-18 21:14
mveCPallini25-May-18 21:14 
GeneralRe: Low profile Pin
RickZeeland25-May-18 22:17
mveRickZeeland25-May-18 22:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Straw Poll

Were you affected by the geomagnetic storms this past weekend?
Communication disruptions, electrified pipes, random unexplained blue-screens in Windows - the list of effects is terrifying.
  Results   429 votes