By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,305 Members | 1,628 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,305 IT Pros & Developers. It's quick & easy.

Reading in a arff file

P: 2
Hey guys,

I cant seem to figure this one out and I looked everywhere for it. My question is how do I read this line of text from an input file into an array

@attribute outlook {sunny, overcast, rainy}

I want to put the word outlook, sunny, overcast, and rainy into an array or just atleast into strings but without the "{" and the ",". I am writing this in c++.

Any suggestions would be appreciated. Thanks
Feb 19 '07 #1
Share this Question
Share on Google+
3 Replies


sicarie
Expert Mod 2.5K+
P: 4,677
Hey guys,

I cant seem to figure this one out and I looked everywhere for it. My question is how do I read this line of text from an input file into an array

@attribute outlook {sunny, overcast, rainy}

I want to put the word outlook, sunny, overcast, and rainy into an array or just atleast into strings but without the "{" and the ",". I am writing this in c++.

Any suggestions would be appreciated. Thanks
You could do them individually. As long as you didn't have too many...
attribute[i] = "sunny"
attribute[i+1] = "overcast"
etc...
Feb 19 '07 #2

Ganon11
Expert 2.5K+
P: 3,652
I think his question is not so much how to get the array working, but how to read that line from a file and be able to separate the words from each other.

I'd start by reading the line into a string variable, and then using .find() to find the 'limits' of each word - for example, to get outlook, you know it is between a space and a '{', so you can use .find() and .substr() to isolate that word.
Feb 19 '07 #3

sicarie
Expert Mod 2.5K+
P: 4,677
I think his question is not so much how to get the array working, but how to read that line from a file and be able to separate the words from each other.

I'd start by reading the line into a string variable, and then using .find() to find the 'limits' of each word - for example, to get outlook, you know it is between a space and a '{', so you can use .find() and .substr() to isolate that word.
That makes much more sense - I got confused with the notation, as that's how you represent an array in PERL.
Feb 19 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.