Computer problems,Computer help
*AX SOFT>>>Programming & Design

What is wrong with my c++ code?


I can't for the life of me figure out what is wrong with this.

for(int y=0; y<FileLength; y++)
{
for(int z=0; z<254; z++); //(b)
{
if(FileData[y] == KeyCodes[z]) //(a)
cout << (char)z;
};
};

I get this error when compiling:
(a) name lookup of `z' changed for new ISO `for' scoping
(b) using obsolete binding at `z'

a and b indicate the lines that the errors point to in my compiler. I am using the Dev-C++ 4.9.9.2 beta.
Any help is appreciated thanks.

Wow. I've read that over like a thousand times and never saw that semicolon. That fixed it. Thanks.

i'm a rookie, but are you sure there is supposed to be a ; (semicolen) ending line (b) ?

isn't line (a) supposed to end in { for the statement on the next line?

for(int y=0; y<FileLength; y++)
{
for(int z=0; z<254; z++) //(b)
{
if(FileData[y] == KeyCodes[z]) { //(a)
cout << (char)z; };
};
};

I suspect there's another definition of z earlier in the function. I'd change the variable in the loop.

Hope that helps.

Edit: The next answerer pointed out the problem: The stray semicolon provides the loop with an empty statement, therefore the now-detached if statement following it is using an obsolete variable.(z).

That dev c++ version is in beta I've had similar problems, you should just use a later version, and listen to cluck, his code seems to work.

Tags
  General - Computers & Internet   Software   Security   Programming & Design   Facebook   Flickr   Google   MSN   MySpace
Related information
  • C++ tcp help?!?!?

    I tried compiling your code. I manage to compile it if I swap the include order of "Ws2tcpip.h" and "winsock2.h". Ie. #include "winsock2.h" #include "Ws2tcpi...

  • Help with embedding code in PHP?

    just keep writing the css you want in the fwrite() function. fwrite($pfile, "<embed src = \"$target_path\ /><p>" . '{font-size:x-small; font-weight:normal; back...

  • Charts in JAVA!?!?!?!?

    The latest - jre 6.0.2. Copy the ".jar" file into the JAVA/JRE/LIB/EXT. Then include the jar file in ur classpath. Then import it. O.K.?

    ...
  • I was extracting a file and it shows me that it got a crc error PLZZ hlp....?

    CRC means "cyclic redundancy check". It is a means of checking the integrity of a file. If it fails the CRC, then that means the file is corrupt. There are no really reliable ways ...

  • Can I change a sub file to srt?

    Hi, Don't do that.. i am almost sure it won't work, but you won't screw up anything since u can rename back your file. If u are up to date with your codecs you should probably no...

  • What programming language are learning or have learned and why?

    Programming languages are for writing programs. Java is the most portable (can be ran on many different operating systems.) .Net is the most popular, simply because it's the most powerful l...

  • Know of any good FREE programmes similar to MS publisher?

    You can try Scribus. It is a freeware Desktop Publishing program. The only downside that I have seen with it is that it does not come with a graphics catalogue. But, you can easily find a boatlo...

  • For loop qustion?

    You have to clear the '' from the buffer before you read the next character. If they were to put more into the buffer, then you should loop until you reach the '' #include<...

  •  

    Categories--Copyright/IP Policy--Contact Webmaster