Attempting to output contents of a text file

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

37 Replies - 724 Views - Last Post: 02 April 2013 - 10:01 AM Rate Topic: -----

#31 mrbondysa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 02-April 13

Re: Attempting to output contents of a text file

Posted 02 April 2013 - 09:18 AM

I understand how to look at them but how would you do it for every character, isn't that too long winded ?
Was This Post Helpful? 0
  • +
  • -

#32 jimblumberg  Icon User is offline

  • member icon


Reputation: 3992
  • View blog
  • Posts: 12,321
  • Joined: 25-December 09

Re: Attempting to output contents of a text file

Posted 02 April 2013 - 09:21 AM

What do you mean by "long winded"? Show me how you print each character in your string one element at a time.

Jim

This post has been edited by jimblumberg: 02 April 2013 - 09:32 AM

Was This Post Helpful? 0
  • +
  • -

#33 mrbondysa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 02-April 13

Re: Attempting to output contents of a text file

Posted 02 April 2013 - 09:24 AM

I mean, wouldn't you have to do it for every string character, from a-z
Something like: if(stringChar == "V")
Was This Post Helpful? 0
  • +
  • -

#34 jimblumberg  Icon User is offline

  • member icon


Reputation: 3992
  • View blog
  • Posts: 12,321
  • Joined: 25-December 09

Re: Attempting to output contents of a text file

Posted 02 April 2013 - 09:33 AM

Nope.

Please answer this question:

Quote

Show me how you print each character in your string one element at a time.



Jim
Was This Post Helpful? 0
  • +
  • -

#35 mrbondysa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 02-April 13

Re: Attempting to output contents of a text file

Posted 02 April 2013 - 09:36 AM

while (!abbrevfile.eof())
	{
		abbrevfile >> newString;
		abbrevVector.push_back(newString);
		cout << newString << " ";
	}


Was This Post Helpful? 0
  • +
  • -

#36 jimblumberg  Icon User is offline

  • member icon


Reputation: 3992
  • View blog
  • Posts: 12,321
  • Joined: 25-December 09

Re: Attempting to output contents of a text file

Posted 02 April 2013 - 09:52 AM

How does that print each individual character of your string?

#include <iostream>
#include <string>

using namespace std;

int main()
{
   string test = "Hello World";

   // Show me how you print each element of the string on it's own line.

   return(0);
}



Jim
Was This Post Helpful? 0
  • +
  • -

#37 mrbondysa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 02-April 13

Re: Attempting to output contents of a text file

Posted 02 April 2013 - 09:55 AM

 
int i = 0;
	for (i; i < abbrevVector.size(); i++)
	{
		int count = 0;	
		int k = 0;
		for (k; k < textFileVector.size(); k++)
		{
			if (abbrevVector[i] == textFileVector[k])
			{
				count++;
			}
		}
		cout << " Element " << abbrevVector[i] << " was found " << count << " times " << endl;
		
	}


Was This Post Helpful? 0
  • +
  • -

#38 jimblumberg  Icon User is offline

  • member icon


Reputation: 3992
  • View blog
  • Posts: 12,321
  • Joined: 25-December 09

Re: Attempting to output contents of a text file

Posted 02 April 2013 - 10:01 AM

That is not what I asked for!

That is not doing anything with the individual characters of your strings. That is working with an entire string.

Show me how you print the individual elements of a string, not a vector.

Please enter the program above and show me how you print the individual elements of the string test, one character per line.

Jim

This post has been edited by jimblumberg: 02 April 2013 - 10:02 AM

Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3