Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Char Pointer Argument/Parameter

Reply
Thread Tools

Char Pointer Argument/Parameter

 
 
Mike Copeland
Guest
Posts: n/a
 
      07-12-2008
How do I distinguish a pointer to a character variable versus a
pointer to a C-type character string? For example,

void Funct1(char *str) // "str" is a character string variable
void Funct2(char *chr) // "chr" is a single character variable

In both cases, I wish to modify the parameter argument, but it seems
to me they are really different data types.
Also, is there any way to _override_ the declaration of a function
with these 2 distinctive data types? Please advise. TIA
 
Reply With Quote
 
 
 
 
Jim Langston
Guest
Posts: n/a
 
      07-12-2008
"Mike Copeland" <> wrote in message
news:...
> How do I distinguish a pointer to a character variable versus a
> pointer to a C-type character string? For example,
>
> void Funct1(char *str) // "str" is a character string variable
> void Funct2(char *chr) // "chr" is a single character variable
>
> In both cases, I wish to modify the parameter argument, but it seems
> to me they are really different data types.
> Also, is there any way to _override_ the declaration of a function
> with these 2 distinctive data types? Please advise. TIA


They actually aren't different types that is. A pointer doesn't care if it
points to one object, or a number of objects. One thing you could do for
yourself to help self document it a little is:

void Func1( char str[] ) // "str" is a character string variable
void Func2( char* chr ) // "chr" is a single character variable

But it really doesn't make a difference. Although I've never seen the []
format used for a single character. You can still pass the address of a
single character to Func1 or Func2, or an array.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
(const char *cp) and (char *p) are consistent type, (const char **cpp) and (char **pp) are not consistent lovecreatesbeauty C Programming 1 05-09-2006 08:01 AM
/usr/bin/ld: ../../dist/lib/libjsdombase_s.a(BlockGrouper.o)(.text+0x98): unresolvable relocation against symbol `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostre silverburgh.meryl@gmail.com C++ 3 03-09-2006 12:14 AM
char *fred; char * fred; char *fred; any difference? Ben Pfaff C Programming 5 01-17-2004 07:37 PM
The difference between char a[6] and char *p=new char[6] ? wwj C Programming 24 11-07-2003 05:27 PM
the difference between char a[6] and char *p=new char[6] . wwj C++ 7 11-05-2003 12:59 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57