Re: [C] simple string question

From: AirPete (x_at_x.x)
Date: 02/05/04


Date: Thu, 05 Feb 2004 03:15:29 GMT

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));

- Pete



Relevant Pages

  • Re: Can I call Obj-C from a C++ source?
    ... The correct code is: ... If the string being substituted in was user input, ... vulnerable to a format string attack. ... That said, if you want to use NSLog from C or C++ code, and have a real reason ...
    (comp.sys.mac.programmer.help)
  • Re: Java program is not evaluating String value correctly...
    ... >:State Abbreviation and compare it for state specific programming. ... >:When it wasn't falling through the correct code, ... The way I'm filling the state abbreviation string ...
    (comp.lang.java.programmer)
  • Re: Field form
    ... >I would like to know how is the correct code that use inside the filed ... Function Combined(Invinitiv As String, Im1 As String) As String ... Dim MyArray() ...
    (microsoft.public.access.forms)
  • Re: [C] simple string question
    ... > Alan wrote: ... >> then in a function at some time, I want to set the string to a ... >> what is the correct code? ... the program crashes ...
    (alt.comp.lang.learn.c-cpp)
  • Re: [C] simple string question
    ... Alan wrote: ... > I want to define a constant length string, ... > what is the correct code? ...
    (alt.comp.lang.learn.c-cpp)