updating an array.

I am pulling in a twitter feed with OF and I would like to add this string data to an array. The following code is pulling in the twitter data.

The specific string data I want in the array is within tweets[i].title. I would like an array to store this data and constantly add to this array, therefore growing a small database.

Could anyone suggest how this may be done?

  
  
void testApp::setup(){  
	  
	twitterPage = 1;  
	  
	twitter.setup();  
	twitter.setSearchDelegate(this);  
	twitter.startTwitterQuery("giggs", 10, twitterPage);  
	  
	millis = ofGetElapsedTimeMillis();  
	  
	  
}  
  
//--------------------------------------------------------------  
void testApp::update(){  
	  
	if ( ABS(ofGetElapsedTimeMillis()-millis) > 10000) {  
		twitterPage = ++twitterPage % 5;  
		twitter.startTwitterQuery("giggs", 10, twitterPage);  
		millis = ofGetElapsedTimeMillis();  
	}  
	  
}  
  
//--------------------------------------------------------------  
void testApp::draw(){  
	  
	ofBackground(255, 255, 255);  
	  
	for(int i=0; i<tweets.size(); i++) {  
		ofSetColor(0, 0, 0);  
		ofDrawBitmapString(tweets[i].author.name, 50, 35+i*40);  
		ofDrawBitmapString(tweets[i].title, 50, 50+i*40);  
		//cout << tweets[i].author.name;  
		cout << tweets[i].title;  
	}  
	  
}  
  
void testApp::searchResult(vector<Tweet> results) {  
	  
	tweets.clear();  
	  
	for(int i=0; i<results.size(); i++) {  
		tweets.push_back(results[i]);  
		cout << results[i].print() << endl << endl;  
	}  
	  
}  
  
  

you could try creating another array to store that collection of strings.

i’d recommend that you use vectors, which are a kind of array that doesn’t have a fixed size (i believe that you’re already using one in your code … called “tweets”)

http://www.cplusplus.com/reference/stl/vector/

so in your code, you could have a vector of strings

vector tweetTitles.

and just push back each new string that you receive in your code.

tweetTitles.push_back(tweets[i].title);

that being said, if you don’t call tweets.clear() in searchResult, then you already have that list of titles!

mantissa