I'm new in C programming, and this is my first assignment. I have completed all the coding, but there's one part doesn't seems to work.
I actually require to build a conceptual washing machine, where I just need to inform the user about the washing mode and choice. To do this, I have created a structure for storing information about the washing details, and I assign a pointer of the structure with malloc(), so that I can free the pointer to save some power during off mode. Here's part of the code:
The problem is here, when it come to the last line, when it try to assign "Small" to the character array "Load".Code:#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct LogInfo //create new name for structure { char DateInfo[10]; char TimeInfo[10]; char Load[25]; char WashMode[10]; char Wash[4]; char Rinse[4]; char Spin[4]; char Soak[4]; int SoakTime; char Temperature[14]; int EstimatedTime; }structure; typedef structure *WashInfoPointer; //create new type (pointer to structure) WashInfoPointer WashInfo; //define a pointer to structure main() { WashInfo = malloc( sizeof(structure)); //malloc and initialize values WashInfo = 0,0,0,0,0,0,0,0,0,0,0; strcpy(WashInfo -> Load, "Small"); //Update washing details return; }
Are there any good solution for assigning "Small" to "Load" without disabling the "malloc"? Or are there any better solution? I have search the web for 2 days, but don't find a solution for this...



LinkBack URL
About LinkBacks



.