Quantcast Most Creative way to write a String!

+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 18
  1. #1
    Notebook Enthusiast
    Join Date
    Jun 2010
    Posts
    37
    Rep Power
    8

    Default Most Creative way to write a String!

    Last week a bonus question for one of my programming assignments was to print out "String" in the most creative/difficult/interesting way you can think of.

    Example: printf("String\n");

    Of course be more creative.

    I thought this might be an interesting topic for NBR. What are your ideas?!

  2. #2
    Stanley Cup Round 2! :)
    Join Date
    Jul 2007
    Location
    at The Joe
    Posts
    25,274
    Rep Power
    131

    Default Re: Most Creative way to write a String!

    Do it in Assembly...


    Code:
    section	.text
        global _start		;must be declared for linker (ld)
    
    _start:			;tell linker entry point
    
    	mov	edx,len	;message length
    	mov	ecx,msg	;message to write
    	mov	ebx,1	        ;file descriptor (stdout)
    	mov	eax,4	        ;system call number (sys_write)
    	int	0x80	        ;call kernel
    
    	mov	eax,1	        ;system call number (sys_exit)
    	int	0x80	        ;call kernel
    
    section	.data
    
    msg	db	'String',0xa	;our dear string
    len	equ	$ - msg	;length of our dear string
    Now you could create a string of letters in hex to create the word "String" and then output that. But I'm too lazy to do that at the moment...
    Last edited by HTWingNut; 26th April 2012 at 06:55 PM.

    Sager NP9150 'Prometheus': 15.6" 1080p matte - i7-3740QM - GTX 680m - 16GB 1600 - 512GB+mSATA 256GB Crucial M4 - Blu-Ray
    Sager NP6110 'Firefly': 11.6" 768p matte - i7-3610QM - GT 650m - 8GB 1600 - 500GB Samsung 840
    Sager Reviews: UPDATED 5/9/13 NP6110 w/650m i5 vs i7 | NP9570 w/680m SLI | NP9370 w/ 680m SLI | NP9150 w/680m | PREMA'S CLEVO BIOS | MOD 680m vBIOS
    My WHS 2011 | HP 6475b A10-4600m | All my other crap

  3. #3
    WaR
    WaR is offline

    Join Date
    Mar 2009
    Posts
    2,128
    Rep Power
    21

    Default Re: Most Creative way to write a String!

    Lol. Nice HTWingNut. As soon as I read the OP, I also thought of Assembly. I'm a little bias towards it since I use it at work everyday for a couple of hours
    M18x.R2
    AMD 7970M CrossFireX™
    Intel® Core™ i7-3720QM
    128GB M4 SSD, 2TB HDD

  4. #4
    NBR Resident Redneck.
    Join Date
    May 2006
    Location
    Deer stand back in the pines.
    Posts
    5,003
    Rep Power
    39

    Default Re: Most Creative way to write a String!

    Code:
    int arr[6];
    int count;
    char input;
    
    for (count=0; count<6; count++)
    {
    cin >> input;
    
    arr[count]=input;
    }
    
    
    for (count=0; count<6; count++)
    {
    
    cout << arr[count];
    }

    Main rig: Dell precision m4600 - 2860QM, firepro 5950, 16GB 1600mhz RAM 9-9-9-28, WLED FDH+, Intel 520 240GB mSata OS, Seagate hybrid 750GB storage.
    Home Web/FTP/SSH Server: Dell precision m4400 Debian squeeze

  5. #5
    Banned
    Join Date
    Feb 2007
    Posts
    5,375
    Rep Power
    0

    Default Re: Most Creative way to write a String!

    Why htwingnut, you know assembly? I is impressed.

  6. #6
    Stanley Cup Round 2! :)
    Join Date
    Jul 2007
    Location
    at The Joe
    Posts
    25,274
    Rep Power
    131

    Default Re: Most Creative way to write a String!

    I know lots of languages... just nothing more than "Hello World!" lol.

    Sager NP9150 'Prometheus': 15.6" 1080p matte - i7-3740QM - GTX 680m - 16GB 1600 - 512GB+mSATA 256GB Crucial M4 - Blu-Ray
    Sager NP6110 'Firefly': 11.6" 768p matte - i7-3610QM - GT 650m - 8GB 1600 - 500GB Samsung 840
    Sager Reviews: UPDATED 5/9/13 NP6110 w/650m i5 vs i7 | NP9570 w/680m SLI | NP9370 w/ 680m SLI | NP9150 w/680m | PREMA'S CLEVO BIOS | MOD 680m vBIOS
    My WHS 2011 | HP 6475b A10-4600m | All my other crap

  7. #7
    Banned
    Join Date
    Feb 2007
    Posts
    5,375
    Rep Power
    0

    Default Re: Most Creative way to write a String!

    I can say hello world in 5 languages. I guess that makes me a real hacker!

  8. #8
    NBA Conference Finals! :)
    Join Date
    Aug 2007
    Location
    Indianapolis, IN
    Posts
    1,004
    Rep Power
    21

    Default Re: Most Creative way to write a String!

    Here's my attempt, using Java:

    char[] theString = "String".toCharArray();
    for (int i = 0; i < theString.length; i++)
    {
    System.out.print(theString[i]);
    }
    System.out.println();

    HP Compaq nw8440 | Core Duo T2600 2.16GHz | 4GB 667MHz DDR2 RAM | 500GB 7200rpm HD
    | DVD±RW DL drive w/ LightScribe | ATi FireGL V5200 256MB GFX | 15.4" 1920x1200 LCD
    | Broadcom a/b/g + Bluetooth | XP Pro w/SP3 + Ubuntu Linux 12.04 (dual boot)

    Sony VAIO VGN-TX770P | Pentium M ULV 1.3GHz | 1.5GB RAM | 80GB 4200RPM HD
    | DVD±RW DL drive | Intel Integrated GFX | 11.1" 1366x768 LCD | Intel b/g + Bluetooth
    | XP Pro w/SP3

    flickr

  9. #9
    Formerly waterwizard11
    Join Date
    Aug 2007
    Location
    On the Edge.
    Posts
    1,315
    Rep Power
    20

    Default Re: Most Creative way to write a String!

    Here's my clever entry (Not tested, but the idea is solid)

    Code:
    //Java
    class myString 
    {
        public static void main(String[] args) 
       {
            System.out.println(this.getClass().getName().substr(2,7)); 
            //print class name, but only chars 2-7
    		
        }
    }

  10. #10
    Notebook Enthusiast
    Join Date
    Jun 2010
    Posts
    37
    Rep Power
    8

    Default Re: Most Creative way to write a String!

    Quote Originally Posted by redrazor11 View Post
    Here's my clever entry (Not tested, but the idea is solid)

    Code:
    //Java
    class myString 
    {
        public static void main(String[] args) 
       {
            System.out.println(this.getClass().getName().substr(2,7)); 
            //print class name, but only chars 2-7
    		
        }
    }
    Care to elaborate on this? I don't quite get what you're trying to do, haha.

    10char

 

 
Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -4. The time now is 12:44 AM.
Powered by vBulletin® Version 4.2.0
Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.
SEO by vBSEO 3.6.0