c - define clear function for win32 && linux -


my question should not hard answer:

i trying write c program train c skills. can't tell on system program run in future.

i want make sure have covered both unix , dos systems.

i trying this:

#ifdef _win32    #define clear()        system("cls"); #endif // _win32  #ifdef linux     #define clear()        system("clear"); #endif // linux 

this seems wrong, tells me

expected declaration specifiers or '...' before string constant" 

although i'm not sure if doing right @ definitions (i include 2 separate headers here example >> more memory used)

there must kind of hard newbish syntax error here.

macro expansion should on same line macro name. if want them on 2 lines, use \ "escape" newline.

#ifdef _win32 #define clear() system("cls"); #endif // _win32  #ifdef linux #define clear() system("clear"); #endif // linux 

or

#ifdef _win32 #define clear() \ system("cls"); #endif // _win32  #ifdef linux #define clear() \ system("clear"); #endif // linux