Find the answer to your Linux question:
Page 2 of 2 FirstFirst 1 2
Results 11 to 12 of 12
If you intent to call the C prog from a webpage, you'd be better off NOT having it take the arguments from STDIN - it would be better to pass ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #11
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353

    If you intent to call the C prog from a webpage, you'd be better off NOT having it take the arguments from STDIN - it would be better to pass them to the prog as command line arguments. Here's an example that takes (requires) two integers as arguments and outputs their sum:

    Code:
    #include <stdio.h>
    int main(int argc, char *argv[]) {
      if (argc != 3) {
        printf("Usage: %s Int1 Int2\n",argv[0]);
      } else {
        printf("%d\n",atoi(argv[1])+atoi(argv[2]));
      }
      return 0;
    }

  2. #12
    Just Joined!
    Join Date
    Oct 2011
    Posts
    34
    thanks mate...i have done it and it is now working very well....i just have to add another header call stdlib.h and use atoi to convert string to integer...anyway thanks for all information.....really appreciate it...

Page 2 of 2 FirstFirst 1 2

Posting Permissions

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