Making own output/input device

This is a discussion on Making own output/input device within the C++ Programming forums, part of the General Programming Boards category; How would someone design a function like cout or printf(). I tried void, but it didn't output anything. Code: void ...

  1. #1
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373

    Making own output/input device

    How would someone design a function like cout or printf().
    I tried void, but it didn't output anything.

    Code:
    void dln(" ")
    {
    cout << " ";
    }
    Thats just an example. I know you wouldn't be able to use
    Code:
    dln("Hello world\n");
    But i was hoping it would output a letter or something.
    This war, like the next war, is a war to end war.

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    Like this?

    Code:
    void myprint(char* blah)
    {
        cout << blah;
    }

  3. #3
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    hey! Thats *kinda* what mine looked like! except i called mine void c(char* 'text')
    maybe i shouldn't use 'text' and use text.
    This war, like the next war, is a war to end war.

  4. #4
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    I'm surprised that char * 'text' didn't give you an error when you compiled it. You should only use alpha-numeric characters for variable names.
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  5. #5
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    yea, maybe. All it did was not output.
    This war, like the next war, is a war to end war.

  6. #6
    Registered User
    Join Date
    Nov 2001
    Posts
    70
    why do that though? it bloats the program and its pointless...
    "...since anyone who is anyone knows C..." -Peter Cellik

  7. #7
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    because i want to master voids.
    This war, like the next war, is a war to end war.

  8. #8
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    What do you mean? A function returning void doesn't return a value. Done - voids mastered...

  9. #9
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    Don't get an attitude with. Watch your tone bud. Not sure which sounds more threatening, so pick one yourself.

    Im still a newbie. I've been programming text games this whole time while getting impssible to compile dos VGA graphics tutorials from Game tutorials.com! Alot of times when i make a void, it won't work.
    This war, like the next war, is a war to end war.

  10. #10
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    > so pick one yourself.

    OK... Chill.

    I'm just saying that it's just a datatype. If a function is specified to return void, it doesn't return a value to whatever called it. There's not really anything to "master" there.

  11. #11
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    Okay, im chillin'.... NO IM NOT!. LOL. Okay, when i have a program like this:
    Code:
    void checknumber();
    int main
    {
    ...
    }
    void checknumber()
    {
    ...
    }
    Why would this error pop up:
    line 56: checknumber() undeclared (first use this function

    ????
    This war, like the next war, is a war to end war.

  12. #12
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    Where's line 56? Is it above where checknumber's defined?

  13. #13
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    the whole program:
    Code:
    #include <iostream>
    void checknumber();
    using namespace std;
    int input;
    int main()
    {
    while (1)
    {
    cout << "Enter a number: ";
    cin >> input;
    checknumber();
    }
    }
    void checknumber()
    {
    cout << "The number you edited is: " << input << ".\n";
    }
    See, no line 56
    Compiler errors like that totally peeve me.
    This war, like the next war, is a war to end war.

  14. #14
    Registered User
    Join Date
    Sep 2002
    Posts
    1,640
    You suuuure there's no line 56? Compilers dont make errors up...

  15. #15
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    17 line file
    This war, like the next war, is a war to end war.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. making smart device cab problem
    By mr_empty in forum Windows Programming
    Replies: 1
    Last Post: 01-08-2008, 03:01 AM
  2. Device Driver: sysfs confusion
    By filker0 in forum Linux Programming
    Replies: 0
    Last Post: 12-02-2005, 11:36 AM
  3. Replies: 4
    Last Post: 06-30-2004, 04:11 PM
  4. making a modem a telephone device
    By ekarapanos in forum C Programming
    Replies: 1
    Last Post: 04-19-2003, 09:56 AM
  5. Device problem
    By John22 in forum C Programming
    Replies: 0
    Last Post: 12-19-2002, 12:02 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21