470,573 Members | 1,679 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,573 developers. It's quick & easy.

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:

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.     char *message = "What's for lunch?";
  6.  
  7.     printf("%s\n", message);
  8.  
  9.     system("pause");
  10.     return 0;
  11. }
  12.  
THANKS FOR YOUR TIME!!!!!!
May 28 '07 #1
5 2801
gpraghuram
1,275 Expert 1GB
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
May 28 '07 #2
svlsr2000
181 Expert 100+
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
May 28 '07 #3
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
May 28 '07 #4
kky2k
34
As far i understood about your requirements here is the solution for ur 1st problem

Code removed as per Posting Guidelines
May 29 '07 #5
svlsr2000
181 Expert 100+
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
May 29 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by tjshadyluver | last post: by
11 posts views Thread by spawn | last post: by
1 post views Thread by mastern200 | last post: by
1 post views Thread by itgetsharder | last post: by
1 post views Thread by livre | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.