char In structures

From: duramax (no_at_email.com)
Date: 05/30/04


Date: Sun, 30 May 2004 12:59:42 -0400

Hi,
I'm getting some weird results for the following code:

#include "stdafx.h"
#include <stdlib.h>
typedef struct ALLO
{
    char a[3];
    char b[4];
} Allo;

int _tmain(int argc, _TCHAR* argv[])
{
    Allo al;
    strcpy(al.a, "aloe");
    strcpy(al.b, "vcxzv");
    return 0;
}

I get an error "stack around arround the 'al' variable was corrupted". I
think that strcpy in this case isn't good but I can't realy tell... If it is
how could I set my char in my structure else than with strcpy?

TIA, Max.



Relevant Pages

  • Re: char In structures
    ... >typedef struct ALLO ... >think that strcpy in this case isn't good but I can't realy tell... ... >how could I set my char in my structure else than with strcpy? ...
    (comp.lang.cpp)
  • Re: char In structures
    ... > typedef struct ALLO ... > how could I set my char in my structure else than with strcpy? ... not be valid memory). ...
    (comp.lang.cpp)