re: C++ compile problems
re: C++ compile problems
- Subject: re: C++ compile problems
- From: George Warner <email@hidden>
- Date: Fri, 25 Jun 2004 08:19:34 -0700
On Fri, 25 Jun 2004 00:49:53 -0400 (EDT), "email@hidden"
<email@hidden> wrote:
> even when I do a g++ compile in terminal, i get the same errors as in Xcode.
> But the errors seem to be incongruent with C++ programming style. Look at my
> code followed by the errors. Any suggestions would be monumental!!! I have a
> C++ programming class and if I can get the C++ compiler to work I would be in
> heaven.
>
>
> int main () {
> string word[]={"Arizona","walk","government","C++","beach");
> int wordsize = sizeof(word)/sizeof(string), i;
> for (int j=0;j<wordsize;j++)
> cout<<word[j]<<" ";
> cout << endln;
> //now pass each word to numberVowels
> for (i=0;i<wordsize;i++)
for (int i=0;i<wordsize;i++)
> {
> cout<<word[i]<<": ",,numberVowels(word[i])<<" vowels"<<endl;
> firstLast(word[i]);
> }
> return 0;
> }
The first for loop declared j as it's index variable; the second uses i. It
could just reuse the same variable. Esp. since "i" and "j" look so similar.
I'd use idx (or wordIndex) instead. Nothing wrong with being verbose (or
explicit). I wouldn't use wordsize (which to me means "sizeof(word)"); I'd
say numWords. And I'd call the array "words" (plural) not "word".
Opinions may differ. ;-)
--
Enjoy,
George Warner,
Schizophrenic Optimization Scientists
Apple Developer Technical Support (DTS)
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.