Thread: Needing assistance with pointers

  1. #16
    Advanced Novice linucksrox's Avatar
    Join Date
    Apr 2004
    Location
    Michigan
    Posts
    198
    siavoshkc, your program has a memory leak. you did not delete your dynamically allocated memory. you should definitely stick with the standard string class for this kind of task, like ChaosEngine said.
    sure it's more of a challenge to use pointers, but it's even MORE of a challenge debugging your memory leaks when you start to have problems...
    "What are all you parallelograms doing here?" - Peter Griffin (to Joe and his wheelchair buddies)

  2. #17
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,246
    I didn't want to use pointers. Look at my first code.
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  3. #18
    Registered User
    Join Date
    Sep 2005
    Posts
    241
    Here it is so far, got one error now
    Code:
    #include <iostream>
    #include <windows.h>
    
    using namespace std;
    int main()
    {
        char *Input;
        char Command[64];
        Input=&Command;
        cin>>Command;
        cout<<*Input;   
        WinExec(Command, 1);
    }
    Oh yeah why do I have to put the number in the WinExec, does it matter what the number is?

  4. #19
    Registered User
    Join Date
    Sep 2005
    Posts
    241
    I dont think char needs refrence operators...

  5. #20
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Code:
    #include <iostream>
    #include <windows.h>
    
    using namespace std;
    int main()
    {
        char *Input;
        char Command[64];
    
        Input = Command;
    
        cin >> Command;
        cout << Input;
    
        WinExec(Command, SW_SHOW);
    }
    The number is a nCmdShow parameter, the same as those you would pass to ShowWindow(..)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using pointers to pointers
    By steve1_rm in forum C Programming
    Replies: 18
    Last Post: 05-29-2008, 05:59 AM
  2. Replies: 4
    Last Post: 12-10-2006, 07:08 PM
  3. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  4. Staticly Bound Member Function Pointers
    By Polymorphic OOP in forum C++ Programming
    Replies: 29
    Last Post: 11-28-2002, 01:18 PM