473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Char Pointer Argument/Parameter

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
Jul 12 '08 #1
2 4820
"Mike Copeland" <mr*****@cox.netwrote in message
news:MP************************@news.cox.net...
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.
Jul 12 '08 #2
mr*****@cox.net (Mike Copeland) wrote:
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
Use this for Funct2:

void Funct2(char& chr);
Jul 12 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Brad Moore | last post by:
Hey all, I'm getting the following compiler error from my code. I was wondering if anyone could help me understand the concept behind it (I actually did try and compile this degenerate...
110
by: Mr A | last post by:
Hi! I've been thinking about passing parameteras using references instead of pointers in order to emphasize that the parameter must be an object. Exemple: void func(Objec& object); //object...
21
by: Bret | last post by:
I'm curious why char** argv is acceptable in the main() declaration. In the comp.lang.c FAQ (question 6.18) it says that pointers to pointers and pointers to an array are not interchangable. ...
19
by: Jasper Dozer | last post by:
Is this a healthy way to get a pointer to point ? char *p = "longenough"; regards, jasper
5
by: jab3 | last post by:
(again :)) Hello everyone. I'll ask this even at risk of being accused of not researching adequately. My question (before longer reasoning) is: How does declaring (or defining, whatever) a...
9
by: Juggernaut | last post by:
I am trying to create a p_thread pthread_create(&threads, &attr, Teste, (void *)var); where var is a char variable. But this doesnt't work, I get this message: test.c:58: warning: cast to pointer...
8
by: andrew.fabbro | last post by:
In a different newsgroup, I was told that a function I'd written that looked like this: void myfunc (char * somestring_ptr) should instead be void myfunc (const char * somestring_ptr) ...
18
by: Pedro Pinto | last post by:
Hi there once more........ Instead of showing all the code my problem is simple. I've tried to create this function: char temp(char *string){ alterString(string); return string;
7
by: =?Utf-8?B?Vmlu?= | last post by:
Hi, I have a question. I created a simple executable program using Visual C++ from Visual Studio 6.0 This program is called from a script that passes in one argument. Now, my question is: ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.