why does this give me an error?
Author |
Message |
Genisis
|
Posted: 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
|
|
|
wtd
|
Posted: 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
|
Posted: 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?
Description: |
|
Download |
Filename: |
Guessing.java |
Filesize: |
6.25 KB |
Downloaded: |
84 Time(s) |
|
|
|
|
|
|
HellblazerX
|
Posted: 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).
|
|
|
|
|
|
|
|