I'm having some trouble with this when it seems as though it shouldn't be hard at all. Yet everytime I try to compile, I get tons of errors and I don't understand why. The code is supposed to read in a pattern of 30 decimal digits into an array of short integers. I need it to read the input stream, report the number of elements read, and then output the number. It should also skip any leading invalid characters and should only read 30 digits. Anything after the first 30 digits should be ignored (using a function from cctype library).
Here's the code I have .. so if anyone could tell me what I'm doing wrong it would be entirely helpful. I'm thinking maybe it's somewhere along the lines of the problem with converting the numbers to an array of short ints?
#include
#include
#include
using namespace std;
const int maxLen=30;
int main()
{
int i;
short pattern[maxLen];
int isdigit(i);
for (i=0;i
cin>>setw(31)>>pattern;
return 0;
}
2007-10-06
19:26:09
·
3 answers
·
asked by
volleyballdawl
2
in
Computers & Internet
➔ Programming & Design
I changed the coding around so I didn't have to use iomanip library. Would this work instead?
int i, maxLen = 30;
short pattern[maxLen];
for (i=0; i
cin.ignore(maxLen, '\n');
return 0;
2007-10-06
19:51:16 ·
update #1
Sorry.. each one acts as an individual value. So for example:
12345 would take up 5 values .. not just one single value.
2007-10-06
20:33:20 ·
update #2