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...
// // Fixed problem trying to modify a fixed string // void myfunction (char message[]);
void myfunction(char message[]){
  ...
» printf("The original text was: %s\n", message); » message1='A'; » printf("The new text is: %s\n", message);
} #define NSTR 3 int main(){
  ...
» char str[NSTR][16]={"Hello, world","abc",""}; » for ( int i=0;i<NSTR; ++i) myfunction(str[i]); » return 0;
}
Memory

myfunction()

128
129
130
131
message = 188

myfunction()

128
129
130
131
message = 204

myfunction()

128
129
130
131
message = 172

main(): for()

168
169
170
171
i = 0

main()

172
173
174
175
str[0] = 'H' 'e' 'l' 'l'
176
177
178
179
180
181
182
183
'o' ',' ' ' 'w' 'o' 'r' 'l' 'd'
184
185
186
187
188
189
190
191
'\0' '\0' '\0' '\0' str[1] = 'a' 'b' 'c' '\0'
192
193
194
195
196
197
198
199
'\0' '\0' '\0' '\0' '\0' '\0' '\0' '\0'
200
201
202
203
204
205
206
207
'\0' '\0' '\0' '\0' str[2] = '\0' '\0' '\0' '\0'
208
209
210
211
212
213
214
215
'\0' '\0' '\0' '\0' '\0' '\0' '\0' '\0'
216
217
218
219
'\0' '\0' '\0' '\0'

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

Show Advanced options

.
Show output (Before looking at the output, work out what you think it put should be and see if you are right.)

Output

The original text was: Hello, world
The new text is: HAllo, world
The original text was: abc
The new text is: aAc
The original text was: 
The new text is: 
                                                                                                                                                                                                                                                                       

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