Page 1 of 1

Can use the getchar() of stdin so debug online is possible

Posted: Sun Oct 22, 2017 8:26 am
by eightmusic

Code: Select all

    int x = 0;
    char a[10];
    char *pa;
    memset(a,0,sizeof(a));
    pa = a;
	while (1)
	{
      x = getchar();       //Get chars that send from UART tool
	  if (x>0)
	  {
		//  printf("x=%d\n",x);
		 if (x == 10)       //Command line end with LF
	     {
		 printf("you send=%s\n",a);
		 //Do something
		 memset(a,0,sizeof(a));
		 pa = a;
	     }else{
	    	*pa = x;
	    	pa++;
	     }
       }
    }