Thread: a lil help "for the lamer"

  1. #1
    Registered User datainjector's Avatar
    Join Date
    Mar 2002
    Posts
    356

    a lil help "for the lamer"

    Okay in the K&R book the question states that i should write a programm called entabs that replases tabs with a certain number of spaces ...
    So this is my problem i tried this

    Code:
    while ( (c = getchar()) != EOF )
              if ( c == '\t' )
                 printf("k");
    since getchar is a bufferen function ...It only work if i press enter ...but i want that when the person presses tab it should print k ...The above code is just for ilustration purpose ...And i dont wanna use unbuffered getche() function because it is not ANSI ...What should i do is there a way to write my own function that does it for me ..if possible how ???
    "I wish i could wish my wishs away"

    "By indirections find directions out" -- William Shakespears

    "Do what thou wilt shall be the whole of the law" -- Crowley "THE BEAST 666"

    Mizra -> love = Death...
    RDB(Rocks yooo)..

    http://www.cbeginnersunited.com

    Are you ready for the Trix ???

  2. #2
    Bios Raider biosninja's Avatar
    Join Date
    Jul 2002
    Location
    South Africa
    Posts
    765
    Try this :

    Code:
    #include <conio.h>
    #include <stdio.h>
    
    int main()
    {
        char c;
        while (c != '1' ) //program terminates uppon pressing 1
        {
            if ( c == '\t' )
            {
                printf("k");
            }
        c = getch();
        }
        return 0;
    }
    The program end when you press "1"

  3. #3
    Registered User datainjector's Avatar
    Join Date
    Mar 2002
    Posts
    356
    boisninja i dont wanna use getch its a non ANSI function and besides that it has it own problems like not moving the cursor to the next line that just one
    "I wish i could wish my wishs away"

    "By indirections find directions out" -- William Shakespears

    "Do what thou wilt shall be the whole of the law" -- Crowley "THE BEAST 666"

    Mizra -> love = Death...
    RDB(Rocks yooo)..

    http://www.cbeginnersunited.com

    Are you ready for the Trix ???

  4. #4
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I have already answered you in your other thread: There is no UNBUFFERED ANSI function for reading input.

    Quzah.
    Hope is the first step on the road to disappointment.

  5. #5
    Bios Raider biosninja's Avatar
    Join Date
    Jul 2002
    Location
    South Africa
    Posts
    765
    I have already answered you in your other thread: There is no UNBUFFERED ANSI function for reading input.
    My point exactly.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A Lil Help With Inheritance...
    By frassunit in forum C++ Programming
    Replies: 16
    Last Post: 03-04-2009, 03:54 AM
  2. A lil controversy: Cloning
    By RoD in forum A Brief History of Cprogramming.com
    Replies: 65
    Last Post: 02-17-2003, 11:19 AM
  3. i need a lil venting.
    By RoD in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 01-03-2003, 10:21 PM
  4. Lil Anti Windows Humor
    By RoD in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 10-02-2002, 12:01 PM
  5. I need a lil help with OS's
    By civix in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 07-18-2002, 10:54 AM