Thread: portable functions

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    20

    portable functions

    does anyone know the metroworks codewarrior equivalent for getch(); and clrscr();
    I'm doing an school assignment and the prob is that it has to compile using the school's out of date software. AND on a mac.

  2. #2
    The Richness... Richie T's Avatar
    Join Date
    Jan 2006
    Location
    Ireland
    Posts
    469
    Google turned this up, might be helpful.
    No No's:
    fflush (stdin); gets (); void main ();


    Goodies:
    Example of fgets (); The FAQ, C/C++ Reference


    My Gear:
    OS - Windows XP
    IDE - MS Visual C++ 2008 Express Edition


    ASCII stupid question, get a stupid ANSI

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    20
    I'm sorry man but that dosen't help

  4. #4
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Is clearing the screen and waiting for any keypress really a requirement? clrscr and getch are very out of date and the former is used by annoying programs. Have you looked for solutions in the FAQ?
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  5. #5
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    Quote Originally Posted by Whizza
    does anyone know the metroworks codewarrior equivalent for getch(); and clrscr();
    I'm doing an school assignment and the prob is that it has to compile using the school's out of date software. AND on a mac.

    For clrscr you could alawys get the dimensions of the screen, and have a function which runs on a for-loop which would press return according to the number of rows there ... there is always this .... I recommend number 5 (for clearing screen)

    for getch(), you may be able to use some variation of kbhit(), but that's in conio too, I think, so it probably won't be any good for you

  6. #6
    Registered User
    Join Date
    May 2006
    Posts
    20
    Damn I thought there might have been a quick compisate function

  7. #7
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,273
    You could create your own one ... but I don't know of any other getch();, or system("pause"); functions ... somebody else may ... you could make your own one ... my making a HUGE array of GetAsyncKeyState(); or whatever it's called ... search through here for examples, and try MSDN.

  8. #8
    Registered User
    Join Date
    May 2006
    Posts
    20
    Never mind according to this link,
    http://www.freescale.com/files/soft_...ual/MSLCRM.pdf ,
    there is a conjagate function for conio.h on macs, its called console.h
    it does both clrscr and getch
    now all I gotta do is test it
    Thanks for the help!!!

  9. #9
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    You could also try this

    cin.get();

    It is used with iostream

    -pete

  10. #10
    Registered User
    Join Date
    Mar 2006
    Posts
    725
    cin::get() waits for the return key. getch() does not.
    Code:
    #include <stdio.h>
    
    void J(char*a){int f,i=0,c='1';for(;a[i]!='0';++i)if(i==81){
    puts(a);return;}for(;c<='9';++c){for(f=0;f<9;++f)if(a[i-i%27+i%9
    /3*3+f/3*9+f%3]==c||a[i%9+f*9]==c||a[i-i%9+f]==c)goto e;a[i]=c;J(a);a[i]
    ='0';e:;}}int main(int c,char**v){int t=0;if(c>1){for(;v[1][
    t];++t);if(t==81){J(v[1]);return 0;}}puts("sudoku [0-9]{81}");return 1;}

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Void Functions Help
    By bethanne41 in forum C++ Programming
    Replies: 1
    Last Post: 05-09-2005, 05:30 PM
  2. Functions and Classes - What did I do wrong?
    By redmage in forum C++ Programming
    Replies: 5
    Last Post: 04-11-2005, 11:50 AM
  3. calling functions within functions
    By edd1986 in forum C Programming
    Replies: 3
    Last Post: 03-29-2005, 03:35 AM
  4. Factory Functions HOWTO
    By GuardianDevil in forum Windows Programming
    Replies: 1
    Last Post: 05-01-2004, 01:41 PM
  5. Shell functions on Win XP
    By geek@02 in forum Windows Programming
    Replies: 6
    Last Post: 04-19-2004, 05:39 AM