Thread: hel plz im lost on pointers

  1. #1
    Registered User
    Join Date
    Feb 2011

    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
    Join Date
    Aug 2010
    Ontario Canada
    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
    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:
    #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
    New Zealand
    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, 07: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, 08:30 AM
  5. Im so lost at . .
    By hermit in forum C Programming
    Replies: 18
    Last Post: 05-15-2002, 01:26 AM