| Sponsored Links |
| | #1 |
![]() Join Date: May 2008 Location: Cheshire
Posts: 17
Thanks: 1
Thanked 2 Times in 2 Posts
Rep Power: 2 | For those who know C++, write a program to display "Hello World". The program must NOT contain any semi colons ( ; ). Good luck |
| |
| | #2 |
![]() Join Date: Nov 2007 Location: Preston
Posts: 98
Thanks: 2
Thanked 4 Times in 4 Posts
Rep Power: 3 | Pretty sure you can do it with in the int main() definition..let me think! there: #include <stdio.h> int main(int argc, char *argv[printf("Hello EDUGEEK\n")]) {} Last edited by el8linuxel8; 15-07-2008 at 11:39 AM.. Reason: completed! |
| |
| | #3 |
![]() Join Date: May 2007 Location: Aberystwyth
Posts: 419
Thanks: 7
Thanked 42 Times in 42 Posts
Rep Power: 11 | 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: Code: #include <stdio.h>
int main(int argc, char **argv)
{
if (printf("Hello Edugeek\n")) {}
}
|
| |
| | #4 |
![]() Join Date: Nov 2007 Location: Preston
Posts: 98
Thanks: 2
Thanked 4 Times in 4 Posts
Rep Power: 3 | josh@liberty:~$ cat temp.c;gcc temp.c -o temp;./temp #include <stdio.h> int main(int argc, char **argv) { if (printf("Hello Edugeek\n")) {} } Hello Edugeek |
| |
| The Following User Says Thank You to el8linuxel8 For This Useful Post: | Jona (15-07-2008) |
| | #5 |
![]() Join Date: Feb 2008 Location: Alcester, Warwickshire
Posts: 1,078
Thanks: 58
Thanked 104 Times in 87 Posts
Rep Power: 22 | Damn, I was nearly there! My C++ is extremely rusty. |
| |
| | #6 |
![]() Join Date: Nov 2007 Location: Wales, UK
Posts: 103
Thanks: 1
Thanked 3 Times in 3 Posts
Rep Power: 3 | 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 |
| |
| | #7 |
![]() Join Date: Nov 2007 Location: Wales, UK
Posts: 103
Thanks: 1
Thanked 3 Times in 3 Posts
Rep Power: 3 | just typing this as you posted |
| |
| | #8 |
![]() Join Date: Nov 2007 Location: Preston
Posts: 98
Thanks: 2
Thanked 4 Times in 4 Posts
Rep Power: 3 | I wouldnt run random C code as root mate |
| |
| | #9 |
![]() Join Date: Nov 2007 Location: Wales, UK
Posts: 103
Thanks: 1
Thanked 3 Times in 3 Posts
Rep Power: 3 | 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.. |
| |
| | #10 | |
![]() Join Date: Dec 2006
Posts: 762
Thanks: 13
Thanked 9 Times in 9 Posts
Rep Power: 10 | Quote:
I would reduce like so: Code: #include <stdio.h>
void main(){ if(printf("Hello World\n")){} }
| |
| |
| |
| | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Test-Um | Ric_ | Recommended Suppliers | 15 | 02-02-2007 10:28 AM |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search Thread |
|
|





