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...
#define LENGTH 26 struct mystruct { float val; char str[LENGTH]; };
int main(){
  ...
» struct mystruct struct1, struct2; » struct1.val=3.14259; » strncpy(struct1.str, "This is the value of Pi!", LENGTH); » struct2=struct1; » » » strncpy(struct1.str, "Oops! No it isn't!", LENGTH); » printf("%s\n%s\n", struct2.str, struct1.str);
}
Memory

main()

132
133
134
135
struct1.val = -4.40284795e+33
136
137
138
139
140
141
142
143
struct1.str = 'h' 'Q' 'N' ' ' '8' ' ' ' ' ' '
144
145
146
147
148
149
150
151
't' ' ' ' ' ' ' ' ' '\0' '\0' '\0'
152
153
154
155
156
157
158
159
' ' ' ' ' ' ' ' ' ' ' ' 'S' ' '
160
161
162
163
164
165
166
167
' ' '\0'
?
?
struct2.val = 2.80259693e-43
168
169
170
171
172
173
174
175
struct2.str = 'G' ' ' 'Y' ' ' '\0' 'P' 'n' ' '
176
177
178
179
180
181
182
183
' ' '\0' '\0' '\0' ' ' ' ' 'Y' ' '
184
185
186
187
188
189
190
191
'8' ' ' ' ' ' ' 't' ' ' ' ' ' '
192
193
' ' '\0'

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

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

This is the value of Pi!
Oops! No it isn't!
                                                                                                                                                                                                                                                                       

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