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

eightmusic
Posts: 2
Joined: Sun Oct 22, 2017 8:12 am

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

Postby eightmusic » Sun Oct 22, 2017 8:26 am

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++;
	     }
       }
    }

Who is online

Users browsing this forum: busadhruv and 109 guests