Most Creative way to write a String!

Discussion in 'Off Topic' started by z0mghii, Apr 26, 2012.

Thread Status:
Not open for further replies.
  1. z0mghii

    z0mghii Notebook Enthusiast

    Reputations:
    0
    Messages:
    38
    Likes Received:
    2
    Trophy Points:
    16
    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. HTWingNut

    HTWingNut Potato

    Reputations:
    21,578
    Messages:
    35,409
    Likes Received:
    9,865
    Trophy Points:
    931
    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... :p
     
  3. WaR

    WaR Notebook Virtuoso

    Reputations:
    2,391
    Messages:
    2,128
    Likes Received:
    0
    Trophy Points:
    55
    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 :)
     
  4. Thaenatos

    Thaenatos Zero Cool

    Reputations:
    1,581
    Messages:
    5,346
    Likes Received:
    126
    Trophy Points:
    231
    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];
    }
     
  5. talin

    talin Notebook Prophet

    Reputations:
    4,694
    Messages:
    5,352
    Likes Received:
    2
    Trophy Points:
    205
    Why htwingnut, you know assembly? I is impressed.
     
  6. HTWingNut

    HTWingNut Potato

    Reputations:
    21,578
    Messages:
    35,409
    Likes Received:
    9,865
    Trophy Points:
    931
    I know lots of languages... just nothing more than "Hello World!" lol.
     
  7. talin

    talin Notebook Prophet

    Reputations:
    4,694
    Messages:
    5,352
    Likes Received:
    2
    Trophy Points:
    205
    I can say hello world in 5 languages. I guess that makes me a real hacker!
     
  8. Teraforce

    Teraforce Flying through life

    Reputations:
    3,053
    Messages:
    1,032
    Likes Received:
    113
    Trophy Points:
    81
    Here's my attempt, using Java:

     
  9. redrazor11

    redrazor11 Formerly waterwizard11

    Reputations:
    771
    Messages:
    1,315
    Likes Received:
    0
    Trophy Points:
    55
    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. z0mghii

    z0mghii Notebook Enthusiast

    Reputations:
    0
    Messages:
    38
    Likes Received:
    2
    Trophy Points:
    16
    Care to elaborate on this? I don't quite get what you're trying to do, haha.

    10char
     
Loading...
Similar Threads - Creative write String
  1. mnd99
    Replies:
    11
    Views:
    958
Thread Status:
Not open for further replies.

Share This Page