Homework help.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • karafire2003
    New Member
    • Apr 2007
    • 10

    Homework help.

    I was wondering if someone can help me with my homework. here's the assignment:
    a. Write a C program that has a declaration in main() to store the string "What's for lunch?" into an array named message. There should be a function call to restaurant() that accepts the message as an argument named menu and then displays the message using the pointer notation *(menu + i).


    b. Modify this restaurant() function to alter the address in message. Use the expression *menu rather than *(menu + i) to retrieve the correct element.

    I don't understand how to do this assignment that's why i am askin for help. I don't understand what's in bold, unfortunately that's the majority of the 2nd half of the assignment. so far i have:

    [code=c]#include <stdio.h>

    int main()
    {
    char *message = "What's for lunch?";

    printf("%s\n", message);

    system("pause") ;
    return 0;
    }
    [/code]

    THANKS FOR YOUR TIME!!!!!!
    Last edited by AdrianH; May 29 '07, 01:28 PM. Reason: Please use [code=c][/code] tags to improve readability.
  • gpraghuram
    Recognized Expert Top Contributor
    • Mar 2007
    • 1275

    #2
    HI,
    You want to alter the address or the value, i am also not able to understand the info told in the requirement 2.
    Can u add more inf then people over here can help u with idea.

    Thanks
    Raghuram

    Comment

    • svlsr2000
      Recognized Expert New Member
      • Feb 2007
      • 181

      #3
      Originally posted by karafire2003
      I was wondering if someone can help me with my homework. here's the assignment:
      a. Write a C program that has a declaration in main() to store the string "What's for lunch?" into an array named message. There should be a function call to restaurant() that accepts the message as an argument named menu and then displays the message using the pointer notation *(menu + i).


      b. Modify this restaurant() function to alter the address in message. Use the expression *menu rather than *(menu + i) to retrieve the correct element.

      I don't understand how to do this assignment that's why i am askin for help. I don't understand what's in bold, unfortunately that's the majority of the 2nd half of the assignment. so far i have:

      #include <stdio.h>

      int main()
      {
      char *message = "What's for lunch?";

      printf("%s\n", message);

      system("pause") ;
      return 0;
      }


      THANKS FOR YOUR TIME!!!!!!
      I guess you have to have a function like this
      restaurant(int menu)

      then u should have some menus
      menu[][] = "Menu1"
      " Menu 2"
      " Menu 3"
      and so on. then once u give menu u have to print the corresponding menu

      Comment

      • karafire2003
        New Member
        • Apr 2007
        • 10

        #4
        i just emailed my instructor to further clarify the question. The question was copied and pasted from my syllabus. THANKS for your time and help

        Comment

        • kky2k
          New Member
          • May 2007
          • 34

          #5
          As far i understood about your requirements here is the solution for ur 1st problem

          Code removed as per Posting Guidelines

          Comment

          • svlsr2000
            Recognized Expert New Member
            • Feb 2007
            • 181

            #6
            Originally posted by kky2k
            As far i understood about your requirements here is the solution for ur 1st problem

            Code removed as per Posting Guidelines
            Your program may work fine, but giving him the source will prohibit his thinking and world would just loose one good programmer

            Comment

            Working...