Thread: pls help urgently

  1. #31
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Quote Originally Posted by rickyspaceguy View Post
    well dear friend i can wish to be accepted as a jackass but not stubborn...im trying to know wat is happening..i use ctrl+z all the time..but the loop won't end so i tried using ctrl+c..

    sumtimes the program is taking ctrl+c as EOF but other times as kill command..

    thts y i m curious abt wat's actually happening

    btw where have u posted the corrected program
    Right here:
    pls help urgently

    Your program wouldn't end right because you had EOF with single quotation marks, around them.

    We told you that, and we told you that was wrong, and we posted the corrected program code.

    But you argue on...

    Ctrl + c just *SEEMS* like it works - but here's the thing: the keyboard buffer is only read and gives input to the operating system, so many times each second. So when you press ctrl + c it may *seem* like it's acting differently, maybe like it's being accepted as EOF by your program:

    It is not!

    It's just that exactly *when* your program is terminated by the ctrl+c, is not going to always be at exactly the same moment, each time. Each keystroke has to be intercepted and read by the OS, and then put into a queue to have that request, done.

    How about something else?

    Code:
    #define ESC 27  //just below your #include files - note - no semi-colon!
    
    int c = 0;
    while((c=getchar()) != ESC) {
       //any other loop logic, in here
    }
    Try that and see if you like it.

  2. #32
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    Location
    in front of my computer
    Posts
    804
    Quote Originally Posted by rickyspaceguy View Post
    thanks ben for the first serious attempt...

    this is the command i give @ my windows cmd prompt alongwith the results..can u still find why is this happening??


    c:\MinGW\bin>mingw32-gcc c:\MinGW\work\count.c -o c:\MinGW\work\count.out

    c:\MinGW\bin>c:\MinGW\work\count.out
    nadbhbb jndsjnsjdn nmnjnssdanj ^Z^Z^C
    c:\MinGW\bin>c:\MinGW\work\count.out
    KDNSLNJBNDJND nsabbsbdjjnsjdn jdsjnjdn
    cznnmn^Z^C
    c:\MinGW\bin>c:\MinGW\work\count.out
    basbgdsja jhjhfdsa
    mnsnnnjkn mmsdm^Z^C
    c:\MinGW\bin>c:\MinGW\work\count.out
    fasjbfbamnbb bbsajbsa
    ^C
    c:\MinGW\bin>c:\MinGW\work\count.out
    jbjsann nsjandjndsn kksak
    nmjbjj
    characters:27 space:3 tabs:0 Newlines:1 ^C
    c:\MinGW\bin>c:\MinGW\work\count.out
    ndsnhhdshbjb jsajbnsajbdfjb jsabjbfbj
    sjfnjfnsjnfs cnnjncj jxzcbjkcjk^Z^C
    c:\MinGW\bin>c:\MinGW\work\count.out
    sjansjnjns jjaBJKBAb JJDBDjnn nj

    characters:33 space:3 tabs:0 Newlines:1
    c:\MinGW\bin>c:\MinGW\work\count.out
    nndsnd,n njknsankd msnansaknklsam kasnknks
    ^C
    c:\MinGW\bin

    ^Z is actually ctrl +Z
    so u can see the program doesnt take @ctrl+z as EOF
    so i tried using ctrl+c..sumtimes it gets executed sumtimes it isnt thts wat bothers me
    i use a MinGW compiler with no ide...i donno whether visual studio ide w'd work...
    Ok. I dont know how to work with Mingw but I guess this is what you're doing wrong.
    You're entering a string like "my name is rickyCtrl+ZCtrl+C"(without double quotes), i.e you're entering ctrl+Z in the same line where the string ends along with ctrl+C followed by it. So the result is ctrl+C terminates the program and the output is 0(for all).
    Now do this as I say(exactly)
    1.Input your string in the first line.
    2. Press Enter where your string ends.
    3.Now in the nextline(important), press Ctrl+Z
    4. Again press Enter, you'll get the correct output.
    Try it and tell us if it solves the problem.
    PS: This is just a wild guess of what you're doing.
    HOPE YOU UNDERSTAND.......

    By associating with wise people you will become wise yourself
    It's fine to celebrate success but it is more important to heed the lessons of failure
    We've got to put a lot of money into changing behavior


    PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
    IDE- Microsoft Visual Studio 2008 Express Edition

  3. #33
    Registered User
    Join Date
    Sep 2009
    Posts
    15

    thnx people

    thnx ben..i've already figured tht out in my prev post...im sorry to people for not figuring it out with the buffer..sorry 4 all the bad blood...but thnx for helping

  4. #34
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,534
    Please, try to avoid the use of 'text speak' in the forums; abbreviated writing is not particularly helpful, and many people find it extremely annoying. In fact, many tech forums forbid the use of this kind of thing. For myself, I am not inclined at all to help people who refuse to type words properly, because I cannot take them seriously. Relating to this, Eric Raymond maintains an article called How to Ask Questions the Smart Way. You will find there some useful advice regarding asking for help on the internet. If you practice what you read, I am fairly certain you will not be annoying people nearly as much as you did in this thread. In particular, read this section:

    Write in clear, grammatical, correctly-spelled language

  5. #35
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Quote Originally Posted by Sebastiani View Post
    Und warum jetzt sprechen wir Deutsch, Abachler?
    Sorry, war gerade im gespräch mit meinen cousins auf dem handy, manchmal dauert es ein oder zwei minuten zu denken in englischer sprache wieder.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. i dont know what to do. pls. help!!!!
    By Unregistered in forum C++ Programming
    Replies: 14
    Last Post: 03-14-2002, 03:24 PM
  2. help me pls..... :(
    By mocha_frap024 in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2002, 10:46 AM
  3. C programming - pls pls help me
    By sally arnold in forum C Programming
    Replies: 10
    Last Post: 01-16-2002, 04:55 AM
  4. pls help me!!
    By hanseler in forum C++ Programming
    Replies: 1
    Last Post: 12-05-2001, 08:46 PM
  5. Pls Help Me In This Question!!!
    By Joanna in forum Windows Programming
    Replies: 1
    Last Post: 10-20-2001, 02:05 PM