You are here

programing class

9 posts / 0 new
Last post
Mir
Mir's picture
Offline
Last seen: 12 years 2 months ago
Joined: 2007-12-03 16:07
programing class

#include

int main()
{
system("cls");
printf("It's a cruel world! I will eat worms");
printf("\n\n\n");
printf("Jan. 20, 2013, The Great Correction will come");
printf("\n\n\n");
printf("Are you talking to me??");
printf("\n\n\n")
}

does this work? i am taking a programing class and because i use linux the way one compiles is a bit different and some of the system commands are different too like cls works in windows but not in linux.

thanks Smile

Aluísio A. S. G.
Offline
Last seen: 8 years 2 months ago
DeveloperTranslator
Joined: 2010-11-09 17:43
--Missing #include-- Nevermind, it's the website
#include <stdio.h>

int main (void) {
    system("clear");
    printf("It's a cruel world! I will eat worms");
    printf("\n\n\n");
    printf("Jan. 20, 2013, The Great Correction will come");
    printf("\n\n\n");
    printf("Are you talking to me??");
    printf("\n\n\n");
    return 0;
}

Previously known as kAlug.

Mir
Mir's picture
Offline
Last seen: 12 years 2 months ago
Joined: 2007-12-03 16:07
what does

the RETURN 0; do?

Ken Herbert
Ken Herbert's picture
Offline
Last seen: 4 hours 32 min ago
DeveloperModerator
Joined: 2010-05-25 18:19
By declaring your function as

By declaring your function as int main() you are telling your compiler that this function will return an int. The return 0; just fulfills this.

Mir
Mir's picture
Offline
Last seen: 12 years 2 months ago
Joined: 2007-12-03 16:07
i noticed a few things

Our professor wants us to use cls. but is clear cross platform?

why is there a main (void)

what does the void part do?

EDIT: Clear does not work with the compiler and setup we atre using.

We in my class are using one of the last 16bit microsoft compilers called C Optimizing Compiler Version 6.0. We are using to make the .c document MS-Dos Editor. this has posed a problem for those using 64bit windows. so far dosbox has not failed me yet Smile

"C 6.0 released in 1989. It added global flow analysis, a source browser, and a new debugger, and included an optional C++ front end.
"

source: http://en.wikipedia.org/wiki/Microsoft_C_compiler#16-bit_versions

Aluísio A. S. G.
Offline
Last seen: 8 years 2 months ago
DeveloperTranslator
Joined: 2010-11-09 17:43
_WIN32 || _MSDOS

Try this:

#if defined(_WIN32) || defined(_WIN16) || defined(_MSDOS)
    system("cls");
#else
    system("clear");
#endif

Previously known as kAlug.

Mir
Mir's picture
Offline
Last seen: 12 years 2 months ago
Joined: 2007-12-03 16:07
thanks

this is an answer to a question i was just about to ask :3

kAlug you are made of win and awesome!

EDIT: Later

That command doesnt work. sorry but it defaults to the CLEAR command and did not work at all on dosbox or in windows using the compiler we are given for class.

Aluísio A. S. G.
Offline
Last seen: 8 years 2 months ago
DeveloperTranslator
Joined: 2010-11-09 17:43
I don't deal with dinosaurs

But try compiling it with /D_WIN16=1.

Previously known as kAlug.

Zach Thibeau
Zach Thibeau's picture
Offline
Last seen: 1 year 11 months ago
Developer
Joined: 2006-05-26 12:08
or with mingw gcc -D_WIN16=1

or with mingw gcc -D_WIN16=1

your friendly neighbourhood moderator Zach Thibeau

Log in or register to post comments