CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Char[] Array Problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
bright_krom



Joined: 11 May 2010
Posts: 3

View user's profile Send private message

Char[] Array Problem
PostPosted: Tue May 11, 2010 3:57 pm     Reply with quote

Hi everyone,
I wanna ask something;
Code:
char *x;
x="Hello";
or
Code:
char x[10];
x="Hello";

These codes are not loading a string to x, how can I do? Help please.

Thanks.
Gabriel



Joined: 03 Aug 2009
Posts: 1067
Location: Panama

View user's profile Send private message

PostPosted: Tue May 11, 2010 4:01 pm     Reply with quote

char x[5] = {'h','e','l','l','o'};

.... if i remember right.. that should do it....

Gabriel.
_________________
CCS PCM 5.078 & CCS PCH 5.093
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue May 11, 2010 4:33 pm     Reply with quote

You can initialize it when you declare the array. Example:
Code:
char x[6] = "Hello";


Or, you can load the array at runtime, by using strcpy:
Code:

char x[6];

strcpy(x, "Hello");
bright_krom



Joined: 11 May 2010
Posts: 3

View user's profile Send private message

PostPosted: Wed May 12, 2010 5:00 am     Reply with quote

Thank you Gabriel and PCM.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group