Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Twitter Counter Using For Loop

$
0
0
Hello, I am working on an assignment in which I need to make a counter to count the characters in a tweet. I need to limit the characters to 140. What I'm trying to do is have a for loop counter that will count whatever characters are in the string - but I'm a bit confused on how to get it to work. I am a HUGE C++ novice, and my teacher has so far been less than helpful. ://>/> I was wondering if you guys could help me out? Here's the code I have so far:

#include <iostream>
#include <string>
using namespace std;

void Tweet()
{
	string tweet;
	int choice;
	while (choice!=1)
	{
		cout<<"Please enter tweet."<<endl;
		getline(cin,tweet);
		for (int i=0; i<140; i++)
		{
			tweet = tweet;
		}
		cout<<"Your Tweet says: "+tweet<< endl;
		cout<<"Is this okay? Enter 1 for YES. Enter 2 for NO."<<endl;
		cin>>choice;
		if (choice == 2)
		{
			cout << "Tweet erased. Please reenter tweet." << endl;
			getline(cin,tweet);
		}

		else if (choice = 1)
		{
			cout << "You have confirmed your Tweet. Saving Tweet for this session."<<endl;
		}
	}
}

int main()
{
	Tweet();
	return 0;
}



EDIT: So - just thinking about it now - I think I have to use some sort of array, but I'm not sure how to go about doing that...:/

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>