Re: [C] simple string question
From: Alan (alanchoiyimlung_at_sinatown.com)
Date: 02/05/04
- Next message: Ben Measures: "Re: Array of Classes or Class with Arrays?"
- Previous message: Ben Measures: "Re: understanding complex declarations."
- In reply to: AirPete: "Re: [C] simple string question"
- Next in thread: AirPete: "Re: [C] simple string question"
- Reply: AirPete: "Re: [C] simple string question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 5 Feb 2004 11:35:56 +0800
"AirPete" wrote:
> Alan wrote:
> > hi all,
> >
> > I want to define a constant length string, say 4
> > then in a function at some time, I want to set the string to a
> > constant value, say a
> > below is my code but it fails
> > what is the correct code?
> > many thx!
> >
> >
> > char string[4] = {0};
> >
> > string = 'a '; /* <-- failed */
>
> memcpy("abcd", string, sizeof(string));
sorry, but it doesn't work
when I run the program, the program crashes
>
> - Pete
>
>
- Next message: Ben Measures: "Re: Array of Classes or Class with Arrays?"
- Previous message: Ben Measures: "Re: understanding complex declarations."
- In reply to: AirPete: "Re: [C] simple string question"
- Next in thread: AirPete: "Re: [C] simple string question"
- Reply: AirPete: "Re: [C] simple string question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|