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...
// // Count the number of letters, digits, punctuation // characters and spaces in a well-known phrase //
void countem(const char string[]){
  ...
» int alphas=0, digits=0, spaces=0, punct=0, others=0; » int i; » for (i=0; stringi; ++i) { » if (isalpha(stringi)) ++alphas; else if (isdigit(stringi)) ++digits; else if (isspace(stringi)) ++spaces; else if (ispunct(stringi)) ++punct; else ++others; } » printf("The string: %s\n" "contains %d letters, %d digits, %d spaces,\n" "%d punctuation characters and %d other characters\n", string, alphas, digits, spaces, punct, others);
} int main(){
  ...
» char hello[]="Hello, world"; » countem(hello); » return 0;
}
Memory

countem()

132
133
134
135
string = 231
136
137
138
139
140
141
142
143
?
?
?
?
alphas = 0
144
145
146
147
148
149
150
151
digits = 0
spaces = 0
152
153
154
155
156
157
158
159
punct = 0
others = 0
160
161
162
163
i = -6842232

main()

231
hello = 'H'
232
233
234
235
236
237
238
239
'e' 'l' 'l' 'o' ',' ' ' 'w' 'o'
240
241
242
243
'r' 'l' 'd' '\0'

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

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 string: Hello, world
contains 10 letters, 0 digits, 1 spaces,
1 punctuation characters and 0 other characters
                                                                                                                                                                                                                                                                       

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