ok Tyler, thanks. On 4/14/11, Littlefield, Tyler <tyler@xxxxxxxxxxxxx> wrote: > the point of getchar is it pulls a char and returns it, which is all you > need. so: > getchar(); > works well enough. it'll let you press enter before the program closes. > On 4/13/2011 7:10 PM, ashish rohtagi wrote: >> hi Ken, you are god! it worked like a charm! thanks. now please tell >> me how to use getchar? take care, regards. ashish >> >> On 4/14/11, ashish rohtagi<ashishrohtagi1969@xxxxxxxxx> wrote: >>> sorry, I corrected the mistake about printf and scanf. thanks for the >>> advice. take care, regards. ashish >>> >>> On 4/14/11, Littlefield, Tyler<tyler@xxxxxxxxxxxxx> wrote: >>>> I'm sorry, getch should be getchar. Also: it's fairly bad coding style >>>> to put a printf on the same line as a scanf. Unless you have good >>>> reason, try to keep your code separated. It makes it easier to read and >>>> people don't miss things quite as easily. >>>> On 4/13/2011 6:50 PM, ashish rohtagi wrote: >>>>> like this?? #include<stdio.h> >>>>> >>>>> int main() >>>>> { >>>>> char me[20]; >>>>> >>>>> >>>>> >>>>> printf("What is your name?"); scanf("%s",&me); >>>>> printf("Darn glad to meet you, %s!\n",me); >>>>> >>>>> scanf("s%",&me); >>>>> >>>>> return(0); >>>>> } but result is still the same. can I use getch fungtion? if yes >>>>> please tell me how to use it . take care, regards. >>>>> >>>>> >>>>> On 4/14/11, Jared Wright<wright.jaredm@xxxxxxxxx> wrote: >>>>>> It goes right between the last printf statement and the return >>>>>> statement. It's job is to hold the program open at the end, so it >>>>>> should >>>>>> be the last statement before return, which ends the program. >>>>>> On 4/13/2011 12:09 PM, ashish rohtagi wrote: >>>>>>> hi Tyler, thanks for your suggestion, but I am unable to understand >>>>>>> where to put second scanf. will you just once show me? take care, >>>>>>> regards. ashish >>>>>>> >>>>>>> On 4/13/11, Littlefield, Tyler<tyler@xxxxxxxxxxxxx> wrote: >>>>>>>> Like ken said, use scanf to catch it before the window closes, or >>>>>>>> run >>>>>>>> it >>>>>>>> in a command line. Here's what's happening: >>>>>>>> You open the process, and the first scanf call blocks; that is to >>>>>>>> say, >>>>>>>> it will not process anything, it is simply waiting for the user to >>>>>>>> input >>>>>>>> something. But after it's done printing, there is no reason why it >>>>>>>> should stay open because you don't tell it to. So run from the >>>>>>>> command >>>>>>>> prompt, use getch() to let you hit enter before it closes or use >>>>>>>> another >>>>>>>> scanf. >>>>>>>> On 4/13/2011 9:32 AM, ashish rohtagi wrote: >>>>>>>>> friends, thanks for all the encouragement. here is my problem, I >>>>>>>>> want >>>>>>>>> to use scanf fungtion. in input and output but as soon as I give my >>>>>>>>> input and press enter the window disappears. it does not give >>>>>>>>> output >>>>>>>>> based on my input. here is the code. #include<stdio.h> >>>>>>>>> >>>>>>>>> int main() >>>>>>>>> { >>>>>>>>> char me[20]; >>>>>>>>> >>>>>>>>> printf("What is your name?"); scanf("%s",&me); >>>>>>>>> printf("Glad to meet you, %s!\n",me); return(0); >>>>>>>>> } >>>>>>>>> >>>>>>>>> >>>>>>>>> On 4/13/11, Littlefield, Tyler<tyler@xxxxxxxxxxxxx> wrote: >>>>>>>>>> O. oops. In my defense, I haven't found coffee. :) >>>>>>>>>> On 4/13/2011 7:46 AM, Jared Wright wrote: >>>>>>>>>>> It's there, just on the same line as the printf statement. >>>>>>>>>>> On 4/13/2011 9:35 AM, Littlefield, Tyler wrote: >>>>>>>>>>>> good job on using int main, just don't forget a return 0; when >>>>>>>>>>>> you >>>>>>>>>>>> are >>>>>>>>>>>> done. between the printf and the closing brace. >>>>>>>>>>>> On 4/13/2011 6:36 AM, ashish rohtagi wrote: >>>>>>>>>>>>> here is my code it compiles correctly but text just shows on >>>>>>>>>>>>> the >>>>>>>>>>>>> screen for 1 second, I want it to stay. #include<stdio.h> >>>>>>>>>>>>> >>>>>>>>>>>>> int main() >>>>>>>>>>>>> { >>>>>>>>>>>>> printf("I will learn programming!\n"); return(0); >>>>>>>>>>>>> } >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>>>> On 4/13/11, DaShiell, Jude T. CIV NAVAIR 1490, 1, 26 >>>>>>>>>>>>> <jude.dashiell@xxxxxxxx> wrote: >>>>>>>>>>>>>> You didn't put your printf statement in your message, but let >>>>>>>>>>>>>> me >>>>>>>>>>>>>> make a >>>>>>>>>>>>>> guess. You didn't put a (\n) in before the closing quote mark >>>>>>>>>>>>>> so >>>>>>>>>>>>>> you >>>>>>>>>>>>>> just put text on the screen without a line ending. That could >>>>>>>>>>>>>> be >>>>>>>>>>>>>> one >>>>>>>>>>>>>> contributing factor. Another might be you didn't put an >>>>>>>>>>>>>> #include >>>>>>>>>>>>>> <stdio.h> statement in at the top of your program and >>>>>>>>>>>>>> maybe >>>>>>>>>>>>>> used >>>>>>>>>>>>>> #include<conio.h>. If that's the case, don't use printf with >>>>>>>>>>>>>> conio.h >>>>>>>>>>>>>> unless you also include stdio.h. For conio.h, cprintf is the >>>>>>>>>>>>>> function >>>>>>>>>>>>>> you want. Hope this helps. >>>>>>>>>>>>>> >>>>>>>>>>>>>> -----Original Message----- >>>>>>>>>>>>>> From: programmingblind-bounce@xxxxxxxxxxxxx >>>>>>>>>>>>>> [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of >>>>>>>>>>>>>> ashish >>>>>>>>>>>>>> rohtagi >>>>>>>>>>>>>> Sent: Wednesday, April 13, 2011 8:04 >>>>>>>>>>>>>> To: programmingblind@xxxxxxxxxxxxx >>>>>>>>>>>>>> Cc: punitdiwan@xxxxxxxxx >>>>>>>>>>>>>> Subject: again a newbee question >>>>>>>>>>>>>> >>>>>>>>>>>>>> friends, sorry here I am with another foolish question, sorry >>>>>>>>>>>>>> but >>>>>>>>>>>>>> here >>>>>>>>>>>>>> is no one to teach and I am learning myself. when I print any >>>>>>>>>>>>>> text >>>>>>>>>>>>>> on >>>>>>>>>>>>>> screen using printf it quickly disappears. what should I do >>>>>>>>>>>>>> that >>>>>>>>>>>>>> it >>>>>>>>>>>>>> should stay? take care, regards. ashish >>>>>>>>>>>>>> __________ >>>>>>>>>>>>>> View the list's information and change your settings at >>>>>>>>>>>>>> //www.freelists.org/list/programmingblind >>>>>>>>>>>>>> >>>>>>>>>>>>>> __________ >>>>>>>>>>>>>> View the list's information and change your settings at >>>>>>>>>>>>>> //www.freelists.org/list/programmingblind >>>>>>>>>>>>>> >>>>>>>>>>>>>> >>>>>>>>>>>>> __________ >>>>>>>>>>>>> View the list's information and change your settings at >>>>>>>>>>>>> //www.freelists.org/list/programmingblind >>>>>>>>>>>>> >>>>>>>>>>>>> >>>>>>>>>>> __________ >>>>>>>>>>> View the list's information and change your settings at >>>>>>>>>>> //www.freelists.org/list/programmingblind >>>>>>>>>>> >>>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> >>>>>>>>>> Thanks, >>>>>>>>>> Ty >>>>>>>>>> >>>>>>>>>> __________ >>>>>>>>>> View the list's information and change your settings at >>>>>>>>>> //www.freelists.org/list/programmingblind >>>>>>>>>> >>>>>>>>>> >>>>>>>>> __________ >>>>>>>>> View the list's information and change your settings at >>>>>>>>> //www.freelists.org/list/programmingblind >>>>>>>>> >>>>>>>>> >>>>>>>> -- >>>>>>>> >>>>>>>> Thanks, >>>>>>>> Ty >>>>>>>> >>>>>>>> __________ >>>>>>>> View the list's information and change your settings at >>>>>>>> //www.freelists.org/list/programmingblind >>>>>>>> >>>>>>>> >>>>>>> __________ >>>>>>> View the list's information and change your settings at >>>>>>> //www.freelists.org/list/programmingblind >>>>>>> >>>>>> __________ >>>>>> View the list's information and change your settings at >>>>>> //www.freelists.org/list/programmingblind >>>>>> >>>>>> >>>>> __________ >>>>> View the list's information and change your settings at >>>>> //www.freelists.org/list/programmingblind >>>>> >>>>> >>>> >>>> -- >>>> >>>> Thanks, >>>> Ty >>>> >>>> __________ >>>> View the list's information and change your settings at >>>> //www.freelists.org/list/programmingblind >>>> >>>> >> __________ >> View the list's information and change your settings at >> //www.freelists.org/list/programmingblind >> >> > > > -- > > Thanks, > Ty > > __________ > View the list's information and change your settings at > //www.freelists.org/list/programmingblind > > __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind