Thread: Parameter problems in C++ applications

  1. #1
    Registered User
    Join Date
    Jul 2006
    Posts
    1

    Parameter problems in C++ applications

    Hi, I created a C++ application called Sujan.exe. In its main method it requires a char array of size 8. here is a copy of my main:
    Code:
    int main(char s[9])//leave space for last character
    {
        cout<<s;
        //I'm not doing anything here, I just want to know
        //whether my program reads in the parameters
    
           return EXIT_SUCCESS;
    }
    Sujan.exe is in the C drive
    In command prompt I try to pass my parameters in various ways, all of which bring up access violations.
    C:/Sujan.exe/"~+02~-03"
    C:/Sujan.exe/~+02~-03
    C:/Sujan.exe "~+02~-03"
    C:/Sujan.exe ~+02~-03

    wats my problem? Am I asking the wrong thing in my C++ program or is my command to the exe flawed so that I cannot access these parameters?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jul 2006
    Posts
    14
    Code:
    int main(int argc, char **argv)
    would help, where argv is an array of character arrays containing your arguments.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  2. my error is storage class specified for parameter
    By meli in forum C Programming
    Replies: 5
    Last Post: 03-27-2009, 12:06 PM
  3. Visual Studio Express 2008 problems.
    By Normac in forum C++ Programming
    Replies: 2
    Last Post: 08-08-2007, 10:41 AM
  4. A question about windows programming
    By Hussain Hani in forum Windows Programming
    Replies: 16
    Last Post: 05-23-2007, 07:38 AM
  5. C Pointers Problems
    By mhelal in forum C Programming
    Replies: 8
    Last Post: 01-10-2007, 06:35 AM