hel plz im lost on pointers

This is a discussion on hel plz im lost on pointers within the C Programming forums, part of the General Programming Boards category; Part 1 In your main() function, ask the user to enter their full name. Ensure that you can successfully store ...

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    1

    hel plz im lost on pointers

    Part 1
    In your main() function, ask the user to enter their full name. Ensure that you can successfully store their name, with the space and without having a Ď\ní character in the array.

    Part 2
    Pass a pointer of your character array into a function that outputs the number of characters stored in your character array.

    Part 3
    Pass a pointer of your character array into a function this displays the reverse.

    Part 4
    Again, passing a pointer to your array, inform the user which character is the space in your name.

    Part 5
    Within your main function, after youíve called the other functions, reverse your name

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Ok, so, sit down and work this one on paper...

    Think about what do you have to do for each step separately.
    Start by tetting the guy's name into a character array.
    Test that it's being correctly stored.

    Move on to the next step...

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Don't get confuzzled by all this "pointer" talk.

    The name of the array, is ALMOST a constant pointer to the first element of the array, and that is how arrays are commonly passed to functions:
    Code:
    #include <stdio.h>
    #include <string.h>
    
    void printIt(char *myname);
    
    int main(void) {
      char myname[] = "Rick";
      printIt(myname); //"myname is the "pointer"
      //other stuff here
    
      return 0;
    }
    void printIt(char *myname) {
      printf("\nMy name is: %s\n", *myname);
    }
    So, what have you been studying for user input of a string, which includes a space, and does not include a newline char?

  4. #4
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,300
    Oooh a list of instructions for you to follow, how nice!
    Now all we need is some questions about it, and the posting of what code you have so far...
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 05-19-2010, 02:12 AM
  2. pointers to arrays
    By rakeshkool27 in forum C Programming
    Replies: 1
    Last Post: 01-24-2010, 06:28 AM
  3. sorting number
    By Leslie in forum C Programming
    Replies: 8
    Last Post: 05-20-2009, 04:23 AM
  4. moving pointers to pointers
    By Benzakhar in forum C++ Programming
    Replies: 9
    Last Post: 12-27-2003, 07:30 AM
  5. Im so lost at . .
    By hermit in forum C Programming
    Replies: 18
    Last Post: 05-15-2002, 01:26 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21