Moicrosoft Visual C++ version 4;
I am trying to write a program that will input some words from a file that will print out. Then theses words that print out put into different categories of for instance 1-character words; 2 character words and so forth until i have a category for words of up to 15 letters. Below i am able to print the words out but need to calculate the length of the word and somehow be able to out them in the space they need to go. I hope to print out all the words then clear the screen, and then have like a calculation pop up with something as "1-character words = " "; i have tried to start it but am just stuck. I am not use to using arrays, but know it is the way to go. So if you could help me out in any way that would be great.

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>

using namespace std;

int counter[16], i;
string word;

int main ( )
  ifstream if1;
  word.length ( );

  if1 >> word;

  while (if1)
     cout << word << " ";
     word.length ( );
     if ( word.length( ) == 1)
        counter[i] = 1

  return 0;

Hello Frank:
   I hope u'll be fine. pardon me, but i was not able to completely understand ur question. As far as i get it, u want to
1) First output all the words in the file.
2) Then u need to print the
  a)number of 1-letter words present in the file.
  b)number of 2-letter words present in the file.
  c)number of 3-letter words present in the file.
    number of 15-letter words present in the file.

If i'm right, plz. confirm it and i'll help u for sure.
Thanks for contacting me


All Answers

Answers by Expert:

Ask Experts




I can answer any questions that range from the very basics of c++ to the advanced topics like polymorphism, inheritance, composition, multiple inheritance and templates. I can also answer almost every type of questions about c++ data structures like stack, queue, circular queue, linklist(single, double, circular), binary trees, binary search trees, avl trees, 2-3 and 2-3-4 trees. I dont have much experience of mfc and creating guis in visual c++, so plz. dont ask me questions about that.


I'm working in c++ since the last 6 years. I've good working skills specially in the advanced topics like inheritance, polymorphism and all type of c++ data structures.

©2017 About.com. All rights reserved.