Pashers Posted July 15, 2008 Posted July 15, 2008 Hey how's it going? For those who know C++, write a program to display "Hello World". The program must NOT contain any semi colons ( ; ). Good luck
el8linuxel8 Posted July 15, 2008 Posted July 15, 2008 (edited) Pretty sure you can do it with in the int main() definition..let me think! there: #include int main(int argc, char *argv[printf("Hello EDUGEEK\n")]) {} Edited July 15, 2008 by el8linuxel8 completed!
Jona Posted July 15, 2008 Posted July 15, 2008 If your allowing the user of if statements this is defiantly possible, I think it's possible by putting it in the main() declaration as well, although I'm not sure if either will result in ANSI valid C.... I reckon: #include int main(int argc, char **argv) { if (printf("Hello Edugeek\n")) {} } Should work.....?
el8linuxel8 Posted July 15, 2008 Posted July 15, 2008 josh@liberty:~$ cat temp.c;gcc temp.c -o temp;./temp #include int main(int argc, char **argv) { if (printf("Hello Edugeek\n")) {} } Hello Edugeek 1
powdarrmonkey Posted July 15, 2008 Posted July 15, 2008 Damn, I was nearly there! My C++ is extremely rusty.
Guest blacksheep Posted July 15, 2008 Posted July 15, 2008 Both work ok [root@sulaco ~]# gcc ./t.c [root@sulaco ~]# ./a.out Hello EDUGEEK [root@sulaco ~]# gcc ./t2.c [root@sulaco ~]# ./a.out Hello Edugeek
Guest blacksheep Posted July 15, 2008 Posted July 15, 2008 Is ok though as straighforward looking printf statement, unless theres some strange C hack there I cant see Now if it was long program or something unusual id after be careful.. A nice script to copy bash with setuid bit set say to a users homedir, have done that before hehe..
Friez Posted September 9, 2008 Posted September 9, 2008 #include int main(int argc, char **argv) { if (printf("Hello Edugeek\n")) {} } Should work.....? Technically not valid as you don't return a value when you exit the main function with a declaration of main as having an int return value (Although may compile depending on the compiler used). I would reduce like so: #include void main(){ if(printf("Hello World\n")){} }
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now