By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,422 Members | 1,323 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,422 IT Pros & Developers. It's quick & easy.

Homework help.

P: 10
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
Share this Question
Share on Google+
5 Replies


gpraghuram
Expert 100+
P: 1,275
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

Expert 100+
P: 181
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

P: 10
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
P: 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

Expert 100+
P: 181
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.