stdio_test.c - demonstrates use of ‘scanf’ forms¶
This program requires inclusion of “pic24_stdio_uart.c”.
#include "pic24_all.h"
#include <stdio.h>
#define BUFSIZE 63
char sz_1[BUFSIZE+1];
int main (void) {
int32_t i32_i;
uint32_t ui32_k;
double d_n;
float f_n;
configBasic(HELLO_MSG);
printf ("This tests 'scanf' stdio; all entries must be terminated by a newline\n");
printf("Input a string (< 63 characters: ");
scanf("%s",sz_1); //get a string from the console
printf("\n");
printf("Entered: '%s' \n",sz_1);
printf("Input an unsigned decimal number: ");
printf("\n");
scanf("%lu",&ui32_k);
printf("The number is: %lu\n",ui32_k);
printf("Input a signed decimal number: ");
printf("\n");
scanf("%ld",&i32_i);
printf("The number is: %ld\n",i32_i);
#if 1
printf("Input a floating point number (single precision): ");
scanf("%f",&f_n);
printf("The number is: %f\n",(double) f_n);
#endif
#if 1
printf("Input a floating point number (double precision): ");
scanf("%lf",&d_n);
printf("The number is: %lf\n",d_n);
#endif
printf ("This concludes the 'scanf' stdio test\n");
while (1) {
doHeartbeat();
}
}