Re: small string question
- From: "Tomás Ó hÉilidhe" <toe@xxxxxxxxxxx>
- Date: Mon, 07 Jan 2008 00:39:47 GMT
"Bill Cunningham" <nospam@xxxxxxxxx> wrote in comp.lang.c:
As I have been studing my tutorial I came up with this question. I
took char passw(char name[]);
In C, you can't pass an array by value. The language's misleading syntax, however, would have you believe that you can. The following three functions are identical:
void Func(char *name) { *name = 0; name = 0; }
void Func(char name[]) { *name = 0; name = 0; }
void Func(char name[72]) { *name = 0; name = 0 }
In the third one, 72 is ignored. All you've got is a non-const pointer in all three cases
and initialied this function in a header with other includes for
standard library headers.
We declare a function in a header file, and define it in a source file. Another name for a declaration is a "prototype". I've never see people use the word "initialiser" though in referring to a function declaration. Here's what an initialiser is in C:
int arr[5] = {7,3,2,3,4};
This doesn't seem to work so is what I want
this?
char passw(char *name);
This is no different from your previous declaration.
I haven't got to pointers in the tutorial and I'm taking my time. But
in this particualr function should it be initialized with a pointer?
Does char *name; equal char name[] ?
Sorry I'm not sure what you're asking.
--
Tomás Ó hÉilidhe
.
- Follow-Ups:
- Re: small string question
- From: Bill Cunningham
- Re: small string question
- From: Bill Cunningham
- Re: small string question
- References:
- small string question
- From: Bill Cunningham
- small string question
- Prev by Date: small string question
- Next by Date: Re: small string question
- Previous by thread: small string question
- Next by thread: Re: small string question
- Index(es):
Relevant Pages
|
|