Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19
Arguments in different languages
Results 1 to 8 of 8

Thread: Arguments in different languages

  1. #1

    Arguments in different languages

    Sounds like a project to me, hehe you could probably do it in shell scripting (not recommended). Speaking of which, I know in a shell script something like this goes
    ./script foo
    and $1 becomes foo, how do command line args work in C, perl, and JAVA (not implying that it's same, just curious).

  2. #2

    Re:Arguments in different languages

    in C:

    Code:
    #include <stdio.h>
    main(int argc, char *argv[]) {
    for(i=0; argv[i] != NULL; i++)
          printf("argv[%d]: %s\n", i, argv[i]);
    }
    in perl:
    Code:
    #!/usr/bin/perl
    foreach(@ARGV) {
    print "$_\n";
    }
    Java I think is similar to C, but I haven't done java in quite a while...

  3. #3

    Re:Arguments in different languages

    In C++, its nearly the same as it is in C:

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main(int argc, char * argv[])
    {
    if (argc > 1) // argv[0] = program_name (unless I am mistaken)
    cout << argv[1];  // Run a loop like the one above by gorn to see all args
    return 0;
    }
    In Java, I am guessing?! :
    Code:
    public static void main (String [] args)
    [update]Try this site and see if it helps:
    http://java.sun.com/docs/books/tutor...dLineArgs.html
    [/update]

  4. #4

    Re:Arguments in different languages

    [quote author=chessforce link=board=9;threadid=8865;start=0#msg80074 date=1079581314]
    In C++, its nearly the same as it is in C:
    [/quote]

    Actually my code would work in C++ or C :-P (all C is that way, C++ however does not workin C)

  5. #5

    Re:Arguments in different languages

    [quote author=gorn link=board=9;threadid=8865;start=0#msg80091 date=1079623683]
    [quote author=chessforce link=board=9;threadid=8865;start=0#msg80074 date=1079581314]
    In C++, its nearly the same as it is in C:
    [/quote]

    Actually my code would work in C++ or C :-P (all C is that way, C++ however does not workin C)
    [/quote]

    Yeah, I meant just pure C++.

    P.S. *Wonders if gorn remembers me*

  6. #6
    Guest

    Re:Arguments in different languages

    5 second C# hack, I dunno if it works.

    Code:
    using System
    
    public class HelloWorld
    {
    static void Main(string[] args)
    {
    Console.WriteLine(args);
    }
    }

  7. #7
    Guest

    Re:Arguments in different languages

    [quote author=Mandrake blows link=board=9;threadid=8865;start=0#msg80140 date=1079709638]
    5 second C# hack, I dunno if it works.

    Code:
    using System
    
    public class HelloWorld
    {
       static void Main(string[] args)
       {
          Console.WriteLine(args);
       }
    }
    [/quote]

    this wouldn't work since the WriteLine method doesn't take an array of strings (it would work if you'd write Console.WriteLine(args.ToString());

    this would work though:

    Code:
    using System;
    
    public class HelloWorld
    {
       static void Main(string[] args)
       {
         foreach string s in args
         {
             Console.WriteLine(s);
         }
       }
    }
    to be honest, i'm not sure if a string array works with foreach and i'm too lazy to look it up right now..

  8. #8

    Re:Arguments in different languages

    Damn...I was hoping to see a spanish guy yelling at an american or something

Similar Threads

  1. GCC can compile how many languages?
    By tech291083 in forum Redhat / Fedora
    Replies: 5
    Last Post: 05-15-2007, 10:03 AM
  2. Blowfish Accross Languages
    By Ashcrow in forum Linux - Software, Applications & Programming
    Replies: 2
    Last Post: 05-20-2006, 11:12 PM
  3. Change languages in open office
    By eypros in forum Linux - Software, Applications & Programming
    Replies: 0
    Last Post: 06-02-2005, 06:49 AM
  4. MOVED: Arguments in different languages
    By gorn in forum General Chat
    Replies: 0
    Last Post: 03-18-2004, 01:35 AM
  5. Replies: 1
    Last Post: 01-22-2003, 09:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •