samedi 18 avril 2015

Unable to read string to a global variable in C

I have the following code :



void main()
{
sscanf("ABC JKL XYZ","%s %s %s",label,mne,opnd);
printf("%s %s %s",label,mne,opnd);
}


where label opnd and mne all are global. However the first string ABC is never being read into label; mne and opnd have values of JKL and XYZ. The most bizarre thing is when I change label to be a local array, the reading works fine! Can anyone tell me what's going on? (and thanks in advance :))


Aucun commentaire:

Enregistrer un commentaire