Click here to Skip to main content
14,772,794 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 798912229-May-18 2:23
MemberMember 798912229-May-18 2:23 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
SawDid29-May-18 10:32
MemberSawDid29-May-18 10:32 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
Bob100029-May-18 0:39
professionalBob100029-May-18 0:39 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
tobofopo29-May-18 2:10
Membertobofopo29-May-18 2:10 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
PIEBALDconsult30-May-18 7:02
professionalPIEBALDconsult30-May-18 7:02 
AnswerRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
Hans Salvisberg29-May-18 2:15
MemberHans Salvisberg29-May-18 2:15 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
Member 1014067829-May-18 2:47
MemberMember 1014067829-May-18 2:47 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
Kirk 1038982129-May-18 2:59
MemberKirk 1038982129-May-18 2:59 
The K&R answer is probably good enough. But I also taught it as the algebraic expression, that
* = 1/& (or * is the inversion of &).

Therefore declaring "char *c" says "*c" is a character, and &(*c) => Pointer, but & and * cancel.
Therefore c is a pointer to a character.

So, if you view it as *c is a the char in question, I think it explains that approach pretty clearly.

Having learned C a VERY long time ago, I have always used, and mostly saw "char *c" or "char c[]"!

the scary part in the old days was explaining how:
13[c] = 'x';

would be handled, as it DID compile!

and according to the answer definition of [] at the time, it was converted to:
*(13+c) = 'x';

and therefore was the same as c[13] = 'x';

GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
nullusDefectus29-May-18 3:11
MembernullusDefectus29-May-18 3:11 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
Hans Salvisberg29-May-18 4:20
MemberHans Salvisberg29-May-18 4:20 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
baemayr29-May-18 4:34
Memberbaemayr29-May-18 4:34 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
SeattleC++29-May-18 5:32
MemberSeattleC++29-May-18 5:32 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
Jesse Connell29-May-18 7:03
MemberJesse Connell29-May-18 7:03 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
jfbode102930-May-18 11:46
Memberjfbode102930-May-18 11:46 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
Jesse Connell30-May-18 18:31
MemberJesse Connell30-May-18 18:31 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
PNutHed29-May-18 7:05
MemberPNutHed29-May-18 7:05 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
englebart29-May-18 12:27
professionalenglebart29-May-18 12:27 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
ClockMeister29-May-18 14:19
professionalClockMeister29-May-18 14:19 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
david garlisch29-May-18 17:59
Memberdavid garlisch29-May-18 17:59 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
jfbode102930-May-18 4:58
Memberjfbode102930-May-18 4:58 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
Chad3F30-May-18 9:53
MemberChad3F30-May-18 9:53 
GeneralRe: Why does most C/C++ developer prefers char *c instead of char* c? Pin
code_junkie31-May-18 4:52
Membercode_junkie31-May-18 4:52 
GeneralLife back to normal Pin
lopatir25-May-18 23:52
Memberlopatir25-May-18 23:52 
GeneralRe: Life back to normal Pin
RickZeeland26-May-18 1:17
mveRickZeeland26-May-18 1:17 
GeneralRe: Life back to normal Pin
OriginalGriff26-May-18 1:31
mveOriginalGriff26-May-18 1:31 

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.