I've never had any weird problems getting my submitted code to be compiled, but all the sudden I can't figure out what's going on.
My C++ program begins:
1 #include <iterator>
2 #include <ctype.h>
3 #include <iostream>
4 #include <vector>
5 #include <algorithm>
6
7 using namespace std;
8
9 string to_caps(const string s) {
10 string out;
11 for (int i = 0; i < s.size(); ++i) {
12 out += toupper(s);
13 }
14 return out;
15 }
and so on. (I didn't include line numbers in my submitted code; they're added here for your convenience.) I'm then told my code won't compile, and returned the following error messages:
Here are the compiler error messages:
04576192_24.c:9: syntax error before `('
04576192_24.c:11: `s' was not declared in this scope
04576192_24.c:11: parse error before `;'
04576192_24.c:20: parse error before `{'
04576192_24.c:24: syntax error before `='
04576192_24.c:26: `s1' was not declared in this scope
04576192_24.c:26: `s1' was not declared in this scope
and so on. This compiles just fine on my computer here, using "powerpc-apple-darwin8-g++-4.0.0 (GCC) 4.0.0 20041026 (Apple Computer, Inc. build 4061)". I've tried submitting both by uploading the file on the submit-o-matic and also by cutting and pasting the code there -- it doesn't make any difference. Can anybody figure this one out?
Bizarre compiler warnings
Moderator: Board moderators