• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Character Array in C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Character Array in C


  • Subject: Re: Character Array in C
  • From: Michael <email@hidden>
  • Date: Mon, 3 Apr 2006 13:32:09 -0700

Thank you all...changing test to type "char" from "void" did the trick.
It fixes this, but I guess leads me to ask this.


If passing a character array is not by value, but by reference, why does it not work to have test as a "void" type? As, if my understanding is correct, ( which it probably is not), what is passed to "test" as an argument is not the "real array" but a pointer to the first byte of the array "helloworld"


Michael.




On Apr 3, 2006, at 1:08 PM, Ben wrote:

test(helloworld) returns void, and yet you are using it as if it would evaluate to a char*.

On Mon, 3 Apr 2006, Michael wrote:

Could anyone please offer some advice:
Trying to play with character arrays in C, the code below generates this error.
Anyone see something wrong?
thank you in advance.



#include <stdio.h>

void test(char s[]);
char helloworld[11];

int main () {
printf("%s", test(helloworld)); // <----Invalid use of void expression
return 0;
}



void test (char t[]) {

t[0]='H';
t[1]='e';
t[2]='l';
t[3]='l';
t[4]='o';
t[5]=' ';
t[6]='W';
t[7]='o';
t[8]='r';
t[9]='l';
t[10]='d';
t[11]='\0';

}

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40silentmedia.com


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Character Array in C
      • From: Jonas Maebe <email@hidden>
References: 
 >Character Array in C (From: Michael <email@hidden>)
 >Re: Character Array in C (From: Ben <email@hidden>)

  • Prev by Date: Re: Debug problem in Multithreaded environment in Xcode.
  • Next by Date: Re: Character Array in C
  • Previous by thread: Re: Character Array in C
  • Next by thread: Re: Character Array in C
  • Index(es):
    • Date
    • Thread