Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 why does this give me an error?
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Genisis




PostPosted: Sun Apr 23, 2006 1:35 am   Post subject: why does this give me an error?

im trying to read one letter form a data file and it gives me the error at

"alpha.read (char lettersguessed [x], 0, 25);"

alpha= the datafile
lettersguessed[x] = the array it ill be stored in
0=offset at which to start storing characters
25= maximum number of characters to read
it will highlight "char" and the error type will be:

"Syntax: unexpected symbol ignored"

any help is aprrecaited thanks
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Sun Apr 23, 2006 1:49 am   Post subject: (No subject)

You'll need to provide more context. Also, please use code tags.

Just guessing, though, I'd say you are not really familiar with how to declare arrays.
Genisis




PostPosted: Sun Apr 23, 2006 1:57 am   Post subject: (No subject)

this is my program can you tell me why its not working like what i will need to add?


Guessing.java
 Description:

Download
 Filename:  Guessing.java
 Filesize:  6.25 KB
 Downloaded:  84 Time(s)

HellblazerX




PostPosted: Sun Apr 23, 2006 8:34 am   Post subject: (No subject)

In your program, here:

code:
for (int x = 0 ; x < 26 ; x++)
     {
           guessed [x] = ' ';
           alpha.read (char lettersguessed [x], 0, 25);
      }

the parameter is read (char [], int, int). Read will read the set of characters, and place in into the array. You should do it like this:
code:
for (int x = 0 ; x < 26 ; x++)
      {
            guessed [x] = ' ';
            alpha.read (lettersguessed, 0, 25);
       }

also, I wasn't sure what the char was supposed to be infront of lettersguessed. Were you trying to typecast, cuz if you were, you need (char).
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: