Please, tell me what can i do... i am a beginner......i have no idea. please....
(if youn need more information please go to download)Mediafire>>> http://www.mediafire.com/?x6ult43663rpv35
Manually walk through the program.Write down the output that you expect will be displayed on screen.
Run the program Observe the result and check for any differences from your expectatation. Explain the difference(if any)
3.Complete the worksheet provide. this program is designed such that you can see the error happen. ignoring string length will either cause progrom crash or data couruption. The worst is that the system may not report any error.
4.Try solving this problem to complete the string copy operation eithout error.
#include <string.h>
#include <stdio.h>
int main(){
// This program is designed only for Visual C++ platform
char * source = "We are very bad",
head[6] = "I am ",
tail[5] ="good",
destination[12];
printf("%s%s%s\n", "before string copy: ", head, tail);
strcpy(destination, source); // copying between two other strings
// not affecting head and tail
printf("%s%s%s\n", "after string copy: ", head, tail);
return 0;
}
(Above the quesion,I already solved the problem.( destination[12]; change to >>destination[18];)
(i don't no how to finish this part) Brfore carrying out any modification to the program, trace the memory contents of all variables for following two statements (assume the statement has just been excuted).
A) char* source="We are very bad",
head[6]="good",
destination[12];
memory Address Memory Content (hex value) Variable Name
_________________________ desination[12]
___________________________
__________________________
___________________________
____________________________ tail[5]
_____________________________ head[6]
B) stropy(destination, source); //copying between two other strings
// not affecting head and tail
memory Address Memory Content (hex value) Variable Name
_________________________ desination[12]
___________________________
__________________________
___________________________
____________________________ tail[5]
_____________________________ head[6]
What is your observation?Is there anything can be done to improve the situation?
Observation:_________________________________
New C statement:____________________________