EH-Net

Ethical Hacking Discussions and Related Certifications => Programming => Topic started by: CTRLS on July 25, 2011, 11:10:57 AM



Title: code block program
Post by: CTRLS on July 25, 2011, 11:10:57 AM
i really need some help right now....my computer isnt running the program that i programmed...as of right now im reading the Teach Yourself C in 21 days and i wrote my first source code it looks something like this

#include<stdio.h>

main()
{
     printf("Hello, World!"/n);
     return 0;
}

and i complie it and try to build and run it but it does nothing!!!!
can someone help me out


Title: Re: code block program
Post by: hell_razor on July 25, 2011, 12:38:34 PM
My C is crap...but shouldn't it be \n not /n ?


Title: Re: code block program
Post by: CTRLS on July 25, 2011, 12:39:17 PM
hmm lemme try it out


Title: Re: code block program
Post by: CTRLS on July 25, 2011, 12:40:27 PM
it just tells me some bs that looks like this:

uses an invalid compiler. Probably the toolchain path within the compiler options is not setup correctly?!


Title: Re: code block program
Post by: hell_razor on July 25, 2011, 12:46:48 PM
Oh yeah, my bad....move the \n inside the quotes, too.

printf("Hello, World!\n");


Title: Re: code block program
Post by: MaXe on July 25, 2011, 12:51:22 PM
i really need some help right now....my computer isnt running the program that i programmed...as of right now im reading the Teach Yourself C in 21 days and i wrote my first source code it looks something like this

#include<stdio.h>

main()
{
     printf("Hello, World!"/n);
     return 0;
}

and i complie it and try to build and run it but it does nothing!!!!
can someone help me out

// Note the space between include and the header.
#include <stdio.h>

main()
{
     printf("Hello, World! \n");
     return 0;
}

It's been ages since I wrote C code, and if anything is wrong with that example, it would probably be the declaration of main() (In some languages you have to use "void" with main as well, but I'm noob so I forgot lol.)

Use Code::Blocks to compile the code as well, if you're on Windows. If you're on Linux, use "gcc". (e.g.: gcc sourcecode.c -o outputfilename )

After you've compiled the executable, if you're on linux, you may have to make it executable like this: chmod +x outputfilename