Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!uwmcsd1!lakesys!davek From: davek@lakesys.UUCP (Dave Kraft) Newsgroups: comp.lang.c Subject: Portability help Keywords: portability, MS-DOS, UNIX, wierd Message-ID: <376@lakesys.UUCP> Date: 12 Feb 89 21:48:16 GMT Organization: Lake Systems - Milwaukee, Wisconsin Lines: 52 Hi, I am taking a C class in school this semester, and the instructor gave us the following example: #include /* Please note: I used in the unix environment */ main() { char a, b, c, d, e; char whats_left[20]; int x; printf("\nKey in a bunch of characters like 1234...9cr: "); scanf("%c%c%c", &a, &b, &c); printf("\nYou typed in >>%c%c%c<<", a, b, c); scanf("%c%c", &d, &e); printf("\nYou had these left over >>%c%c<<", d, e); putc('\n', stdout); scanf("%s", whats_left); printf("\n>>%s<<", whats_left); printf("\n>>%s<<", &a); x = getchar(); if(x == EOF) printf("\nInput stream empty."); else; printf("\nGot back >>%d%x<<", x, x); } I have entered and compiled this on Turbo C 1.5, and it runs like it should. I enter: 123456789 and the first thing it prints is the >>123<<, then >>45<<, then >>6789<<, then >>123456789<<, and I get 'Got back >>10a<<' On the Unix system I enter the same numbers, and I get >>123<< >>45<< >>6789<< and here's one of the kludges: >>126789<<, and for 'Got back', it shows >>00<<.. Why? Also, when I try to re-direct as follows: 1) example > output 123456789 (<-- what I type in after (1)) then I get a core dump, and a message (do not remember exactly, will redo and post) 2) example < numlist > output (numlist contains 123456789) I get the same core dump as in (1). Why?? Any help would be appriciated. Dave ); -- davek@lakesys.lakesys.com uunet!marque!lakesys!davek