h, i am student and study C programming, by lab-windows CVI.. in GUI i have create text-box and list-box... i read from a file to text-box and the user, searches after a word... when it is matched, it should appears the word in the list-box... i have used a character word, (first as pointer or an array) but used a keyword to put the word in the list-box, but i get error that: it is pointed to char and expect char. i changed it to simple character, but it complains that it is small, even i have allocated... i hope that you can solve my problem.. appreciate... `int i=0, textLength; char str[80], word1[25], word2;
static FILE *ifp;
switch (event)
{
case EVENT_COMMIT:
ifp = fopen ("text.txt", "r");
while((fgets(str,80,ifp))!=NULL) {
SetCtrlVal (panelHandle, PANEL_TEXTBOX, str);
SetCtrlVal (panelHandle, PANEL_TEXTBOX, "\n");
++i;
}
rewind(ifp);
GetCtrlAttribute (panelHandle, PANEL_STRING, ATTR_STRING_TEXT_LENGTH, &textLength);
word2 = (char) malloc (sizeof(char) * (textLength + 1));
GetCtrlVal (panelHandle, PANEL_STRING, &word2); //argument too small using usual char
while((fscanf(ifp,"%s",word1))!=EOF){
if(strcmp(word1,&word2)==0){
SetCtrlVal(panelHandle, PANEL_LISTBOX, word2); //get error, it is pointed to char and expect char (when *word2 or word[25]) ?!!
if ((panel2 = LoadPanel (0, "ex1.1.1.uir", PANEL_2)) < 0)
return -1;
DisplayPanel (panel2);
SetCtrlVal(panel2,PANEL_2_TEXTMSG,"match found");
}
}
break;`