Skip to content
EMPS intranet

Back to top
Hi!   Hi!           Start main()

Try stepping through the code


  Value and type of last evaluated expression: Address of array element: Address of array elementx:  (none)

Your browser does not support the canvas element which will make some the features unavailable.

If you are using Internet Explorer within the University of Exeter try going to the Settings menu (probably the gear shape at the top right of this page), selecting "Compatibility View settings", unchecking "Display intranet sites in Compatibility View" and reloading this page.

Code

 Header...
// // Demonstrate problem trying to modify a fixed string // void myfunction (char message[]);
void myfunction(char message[]){
  ...
» printf("The original message was: %s\n", message); » message0='A'; » printf("The new message is: %s\n", message);
} int main(){
  ...
» myfunction("Hello, world");// Subtle error! » return 0;
} // This program failed to complete properly // See if you can work out why by // stepping throught the code.
Memory

Fixed strings

134
135
'T' 'h'
136
137
138
139
140
141
142
143
'e' ' ' 'o' 'r' 'i' 'g' 'i' 'n'
144
145
146
147
148
149
150
151
'a' 'l' ' ' 'm' 'e' 's' 's' 'a'
152
153
154
155
156
157
158
159
'g' 'e' ' ' 'w' 'a' 's' ':' ' '
160
161
162
163
164
165
166
167
'%' 's' '\n' '\0'
?
?
?
?
224
225
226
227
228
229
230
231
?
?
'H' 'e' 'l' 'l' 'o' ','
232
233
234
235
236
237
238
' ' 'w' 'o' 'r' 'l' 'd' '\0'

myfunction()

368
369
370
371
message = -4158856982

NB: the actual memory address of each variable is the
address shown plus 4293392048 (0xFFE7F6B0).

Show Advanced options

.
                                                                                                                                                                                                                                                                       

Validate   Link-check © Copyright & disclaimer Share
Back to top