strcpy - problem!!!
I tried looking for threads for strcpy specifically for my problem but i just can't find the specific answers. Anyway, here's my problem....
I am trying to copy an array of string to my structure but i'm always getting an Unhandled Exception and points me to strcat.asm. Actually it is weird because in my program, it was not having the error not until i changed the value i passed. I tried several approach to test and debug why it is happening but it just keeps on giving the error.
Below is a snippet of my code for your reference. I'm trying to copy a string to two differently declared structures. I hope someone could help me... ASAP! :(
I am having the exception at "strcpy(lst_personalInfo->sName, lst_fieldValues.sValue);" and I don't know why. Please help.
typedef struct st_personal_info
typdef struct st_field_values
char lsToPass = "MICHAEL";
Many thanks everyone!
You need to allocate memory for the record pointer.
ST_PERSONAL_INFO *lst_personalInfo = malloc(sizeof(ST_PERSONAL_INFO));
Don't forget to free it when you're done.
Im familiar with the "new" call for C++ so seeing the C version is new for me.
Is there any difference between malloc and new?
edit: oops! didnt notice the C board
JohnLeeroy, new() is strictly a C++ function. This is the C forum, it's safe to assume that using C's malloc is required.
Oh, and cross-posted.
Well, at some point new probably calls malloc() but it also includes logic to activate constructors in classes.
Originally Posted by JohnLeeroy
Malloc just gives you a blob of memory to work with.
I tried your solution. Well... it worked! thanks a lot! really appreciate it!
Originally Posted by CommonTater