Buy an Axon, Axon II, or Axon Mote and build a great robot, while helping to support SoR.
0 Members and 1 Guest are viewing this topic.
scanf("%d",&z);
It works with numbers But is it possible to do this with words?thanks.
int main ( void ){ unsigned char z[256] ; while(1) { printf("Enter your string: \r\n"); scanf("%s",&z); printf("You mean %s?\r\n",z); }}
Code: [Select]int main ( void ){ unsigned char z[256] ; while(1) { printf("Enter your string: \r\n"); scanf("%s",&z); printf("You mean %s?\r\n",z); }}
scanf("%s",z);
Hi there,You defined z as 16-bit integer and try to put string into it: scanf("%s",&z);.I've never done this before, but I know that strings in AVR GCC are char[] (array of chars). So, writing this should do the trick:Code: [Select]int main ( void ){ unsigned char z[256] ; while(1) { printf("Enter your string: \r\n"); scanf("%s",&z); printf("You mean %s?\r\n",z); }}
if (strcmp ("hello", string) == 0){ // found "hello"}else{ // not "hello}
Try the following:float temp = ICR1 * x / 20.0;OCR1A = (uint16_t)temp;