Scanf is not working in posix sample

Thomas Doerfler Thomas.Doerfler at imd-systems.de
Sat May 21 06:13:11 UTC 2005


Jason,

it might have been late when you tried out this code, but... scanf does
not work that way. You can't put a prompt text into the first parameter
of scanf. Try out this one: replace your scanf line with:

	printf("Eingabe: ");
	scanf("%d",&nummer);

wkr,
Thomas.


Jason Davis schrieb:
> Hello,
> 
> I modified a posix printf example slightly with an additional scanf. But I
> can't figure out why the program is not running. It starts and shows the
> printf "Hello World" string but the it stops without any possible input via
> keyboard. I'm using a PC board with a PIII.
> 
> I added the test.c file and my makefile below. Any ideas?
> 
> Regards,
> Jason
> 
> The test.c file:
> 
> /*
>  *  Simple test program -- simplified version of sample test hello.
>  */
> 
> #include <bsp.h>
> 
> #include <stdlib.h>
> #include <stdio.h>
> #include <stdlib.h>
> 
> void *POSIX_Init(
>   void *argument
> )
> {
>   int nummer;
>   printf( "\n\n*** HELLO WORLD TEST ***\n" );
>   printf( "Hello World\n" );
>   scanf("Eingabe: %d",&nummer);
>   printf( "*** END OF HELLO WORLD TEST ***\n" );
>   exit( 0 );
> }
> 
> /* configuration information */
> 
> #define CONFIGURE_TEST_NEEDS_CONSOLE_DRIVER
> 
> #define CONFIGURE_POSIX_INIT_THREAD_TABLE
> 
> #define CONFIGURE_MAXIMUM_POSIX_THREADS 2
> 
> #define CONFIGURE_INIT
> 
> #include <confdefs.h>
> 
> /* end of file */
> 
> And my makefile:
> 
> #
> #  Makefile
> #
> 
> #
> #  RTEMS_MAKEFILE_PATH is typically set in an environment variable #
> 
> EXEC=hello.exe
> PGM=${ARCH}/$(EXEC)
> 
> # optional managers required
> MANAGERS=io
> 
> # C source names
> CSRCS = test.c
> COBJS_ = $(CSRCS:.c=.o)
> COBJS = $(COBJS_:%=${ARCH}/%)
> 
> # C++ source names
> CXXSRCS =
> CXXOBJS_ = $(CXXSRCS:.cc=.o)
> CXXOBJS = $(CXXOBJS_:%=${ARCH}/%)
> 
> # AS source names
> ASSRCS =
> ASOBJS_ = $(ASSRCS:.s=.o)
> ASOBJS = $(ASOBJS_:%=${ARCH}/%)
> 
> # Libraries
> LIBS = -lrtemsall -lc
> 
> include $(RTEMS_MAKEFILE_PATH)/Makefile.inc
> 
> include $(RTEMS_CUSTOM)
> include $(PROJECT_ROOT)/make/leaf.cfg
> 
> OBJS= $(COBJS) $(CXXOBJS) $(ASOBJS)
> 
> all:    ${ARCH} $(PGM)
> 
> $(PGM): $(OBJS)
> 	$(make-exe)
> 
> j:
> 	@echo $(CFLAGS_DEBUG_V)
> 	@echo $(RTEMS_USE_GCC272)


-- 
--------------------------------------------
IMD Ingenieurbuero fuer Microcomputertechnik
Thomas Doerfler           Herbststrasse 8
D-82178 Puchheim          Germany
email:    Thomas.Doerfler at imd-systems.de
PGP public key available at:
     http://www.imd-systems.de/pgp_keys.html



More information about the users mailing list