Xref: utzoo comp.sys.mac.programmer:20821 comp.sys.mac.misc:7685 Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!apple!fernwood!portal!cup.portal.com!David_Anthony_Guevara From: David_Anthony_Guevara@cup.portal.com Newsgroups: comp.sys.mac.programmer,comp.sys.mac.misc Subject: MPW C 3.1 scanf problem Message-ID: <38337@cup.portal.com> Date: 22 Jan 91 04:10:26 GMT Distribution: usa Organization: The Portal System (TM) Lines: 26 I have a (hopefully) real simple problem. I am using MPW C 3.1 to do some programming for a C class. What I want to do is to prompt the user and leave the cursor at the end of the prompt line. My problem is that scanf will not read the input if the cursor is at the end of the prompt line. I have to start on a newline for scanf to get the value. Example code: #include main() { int input1; printf("Input an integer value: "); /* cursor is at end of line */ scanf("%d",&input1); printf("input1 = %d\n",input1); } If I put a newline in after the prompt, the scanf works. If I leave the code as stated above, I'll get some garbage. I'm building this under MPW as a tool. Is this a known problem/undocumented feature of MPW C? I've compiled the same code under Think C 4.02 and Turbo C with no problem. E-mail me your responses. I'm sure this is too elementary to waste on the net. As always, I will summarize to the net if there is sufficient interest. Dave Guevara, Internet: David_Anthony_Guevara@cup.portal.com