Help with pointers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gemacjr1201
    New Member
    • Nov 2006
    • 14

    #1

    Help with pointers

    I can't figure out how to fix this,can any one help me please:


    void main()
    {
    char string[20];
    char *aString=string ;
    function(aStrin g);
    }
    void function(char *name)
    {
    cout << "enter name";
    cin >> *name;
    cout << name;
    }
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    cin >> name;

    Comment

    • vamsilatha
      New Member
      • Oct 2006
      • 1

      #3
      #include <iostream.h>
      #include <stdlib.h>
      i think like this your program should be



      void function(char *name)
      {
      cout << "enter name";
      cin >> name;
      cout << name;
      }


      void main()
      {
      char string[20];
      char *aString=string ;
      function(aStrin g);
      }

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        Actually

        void main()

        is wrong to an will invoke undefined behaviour, it should be

        int main()

        and you should return a value from main

        Comment

        Working...