ATTN: C++ programmers

Discussion in 'OT Technology' started by Black Light, Mar 9, 2004.

  1. Black Light

    Black Light Guest

    [​IMG]

    So... I tried to compile it in MS Visual C++... However it wouldn't work until I used the following version:
    Code:
    void main()
    {
    char msg[]={78, 111, 119, 32, 72, 105, 114, 105, 110, 103, 0};
    puts(msg);
    }
    It works, but I'm getting a warning:
    :wtf: :confused:
     
  2. EkriirkE

    EkriirkE Zika Xenu OT Supporter

    Joined:
    Jan 11, 2004
    Messages:
    14,799
    Likes Received:
    0
    Location:
    Dublin & San Francisco, CA
    #include what?



    #include "stdio.h"
    I believe
     
  3. Penguin Man

    Penguin Man Protect Your Digital Liberties

    Joined:
    Apr 27, 2002
    Messages:
    21,696
    Likes Received:
    0
    Location:
    Edmonton, AB
    #include <stdio.h> actually (unless stdio.h is in the same directory as the text file).
     
  4. Black Light

    Black Light Guest

    :bowdown: :bowdown: :bowdown:

    Code:
    #include <stdio.h>
    
    void main()
    {
    char msg[]={78, 111, 119, 32, 72, 105, 114, 105, 110, 103, 0};
    puts(msg);
    }
    :bowdown: :bowdown: :bowdown:
     
  5. EkriirkE

    EkriirkE Zika Xenu OT Supporter

    Joined:
    Jan 11, 2004
    Messages:
    14,799
    Likes Received:
    0
    Location:
    Dublin & San Francisco, CA
    Its all the same, I've never had problems.

    ..and don't go rule-book thumping!
     
  6. Black Light

    Black Light Guest

    :rofl: :Owned:
     
  7. SL1200MK4

    SL1200MK4 New Member

    Joined:
    Sep 27, 2003
    Messages:
    1,552
    Likes Received:
    0
    Gcc is a lot more than just a c compiler, it's a collection of various compilers. If you are refering to the command gcc, well yes usually people use it to compile C and use g++ for C++. However g++ itself is a script that wraps gcc for C++ compiling work. Correct me if I am wrong.

    Also while the thread topic states ATTN: C++ programmers. The program itself doesn't have any C++ specific elements that I see. So, technically it can be a C program.

    On top of all that, you don't have to include stdio.h in a cpp program. Most of the time, you use #include<iostream> instead.

    Also, if this program would to be a C++ program, it will not compile with later versions of gcc. Because after version 3.0 I believe, they don't assume that you use namespace std, which was given to you previous in the older version of gcc.
     
  8. RaginBajin

    RaginBajin Have you punched a donkey today?

    Joined:
    Dec 24, 2001
    Messages:
    8,740
    Likes Received:
    0
    Location:
    NoVA
    Totally awesome though.. I love it.
     
  9. Black Light

    Black Light Guest

    Now we need a backwards converter in C++ so we can send secret messages to each other :naughty:
     
  10. StevesVR4

    StevesVR4 Get Arrested

    Joined:
    Jul 1, 2003
    Messages:
    7,328
    Likes Received:
    0
    Actually, specifying the namespace is dependent on the header file you include. If you #include <iostream>, then you need to use the std namespace. But, if you #include <iostream.h>, then you don't need to use the std namespace.
     
  11. ez4me2c3d

    ez4me2c3d Guest

    wow, all it is ascii character codes for alphabet letters.
    any program can convert this, not just C.

    VBScript
    Copy and past this code into a text document and make sure the extension is vbs.
    Code:
    msg = array(78, 111, 119, 32, 72, 105, 114, 105, 110, 103, 0)
    for each letter in msg
    newmsg = newmsg & chr(letter)
    next
    msgbox newmsg
    then double click it.
     
  12. Black Light

    Black Light Guest

    :eek3: :cool:
     
  13. EkriirkE

    EkriirkE Zika Xenu OT Supporter

    Joined:
    Jan 11, 2004
    Messages:
    14,799
    Likes Received:
    0
    Location:
    Dublin & San Francisco, CA
    :rolleyes:

    .CODE
    Start:
    PUSH 0
    PUSH OFFSET title
    PUSH OFFSET msg
    PUSH 0
    CALL MessageBoxA
    PUSH 0
    CALL ExitProcess
    title DB "The message",0
    msg DB 78, 111, 119, 32, 72, 105, 114, 105, 110, 103, 0
    END Start
     
  14. ez4me2c3d

    ez4me2c3d Guest

    everyone has there languages...but uhm..yeah what language is that in?
     
  15. Black Light

    Black Light Guest

    Is that written in Assembler? :eek4d:
     
  16. EkriirkE

    EkriirkE Zika Xenu OT Supporter

    Joined:
    Jan 11, 2004
    Messages:
    14,799
    Likes Received:
    0
    Location:
    Dublin & San Francisco, CA
    Mmm, I love C programming fights, esp. when it gets down to rule book(bible) quoting(thumping)
    Actually, not. No offense. Well, not really.
    And, yeah, that's x86 assembly
     
  17. hast

    hast Guest

    Code:
    .assembly Hiring {}
    
    .method static public void main() il 
    {
      .entrypoint
      
      .locals init([0] char[] msg)
      ldc.i4.s 10
      newarr [mscorlib]System.Char
      stloc.0
    
      ldloc.0
      ldc.i4.0
      ldc.i4.s 78
      stelem.i2
    
      ldloc.0
      ldc.i4.1
      ldc.i4.s 111
      stelem.i2
      
      ldloc.0
      ldc.i4.2
      ldc.i4.s 119
      stelem.i2
    
      ldloc.0
      ldc.i4.3
      ldc.i4.s 32
      stelem.i2
     
      ldloc.0
      ldc.i4.4
      ldc.i4.s 72
      stelem.i2
    
      ldloc.0
      ldc.i4.5
      ldc.i4.s 105
      stelem.i2
    
      ldloc.0
      ldc.i4.6
      ldc.i4.s 114
      stelem.i2
    
      ldloc.0
      ldc.i4.7
      ldc.i4.s 105
      stelem.i2
    
      ldloc.0
      ldc.i4.8
      ldc.i4.s 110
      stelem.i2
    
      ldloc.0
      ldc.i4.s 9
      ldc.i4.s 103
      stelem.i2
    
      ldloc.0
      call void[mscorlib]System.Console::WriteLine(char[])
    
      ret
    }
    
     
  18. ez4me2c3d

    ez4me2c3d Guest

    Thats sick... 66 lines of code??? :eek3:
    Mine's only 5 lines. ;)
     
  19. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    :bowdown: i see we have another assembler programmer :bowdown:
     
  20. EkriirkE

    EkriirkE Zika Xenu OT Supporter

    Joined:
    Jan 11, 2004
    Messages:
    14,799
    Likes Received:
    0
    Location:
    Dublin & San Francisco, CA
    I love assembly :love:

    Unfortunately it's not the greatest for porting :wtc:
     
  21. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    oh well, aslong as i can put it in C as a sub routine im happy :)

    and its REAL ASM, not MASM crap.

    Arrow ASM > *

    :big grin:
     
  22. EkriirkE

    EkriirkE Zika Xenu OT Supporter

    Joined:
    Jan 11, 2004
    Messages:
    14,799
    Likes Received:
    0
    Location:
    Dublin & San Francisco, CA
    :( I MASM
    I don't like inline assembly, I make and link compiled obj/lib files to my projects...
    eg my own CRT for MSVC. I cannot stand their static-linked CRT which includes everything even what you don't use, and I don't like using the CRT DLL to keep distributed files down.
     
  23. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    java code: (since it hasnt been posted)
    Code:
    public class Hire{
    	public static void main(String[] args){
    		int[] list = {78, 111, 119, 32, 72, 105, 114, 105, 110, 103, 0};
    		StringBuffer buf = new StringBuffer();
    		for(int i=0;i<list.length;i++){
    			buf = buf.append((char)list[i]);
    		}
    		System.out.println(buf);
    	}
    }
    
     
  24. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    sorry to hear u love masm.... i tried using masm after my asm class and i wanted to smash my head into a brick wall after playing with it....

    i could of just had a bad experience with it... ill give it another try at the end of semester
     
  25. EkriirkE

    EkriirkE Zika Xenu OT Supporter

    Joined:
    Jan 11, 2004
    Messages:
    14,799
    Likes Received:
    0
    Location:
    Dublin & San Francisco, CA
    Yeah, it sucks that all the assemblers use different syntax to define macros, routines, etc. - I have to edit my sources when moving it over to nasm/tasm...
    But past all that, the instructions are basically the same.
     

Share This Page