The code works great, but I am trying to add the length of the each name to the vector. Can someone please show me how to declare a two(2) dimensional vector? I simply want to modify the existing vector to have another dimension of number?
#include <iostream>
#include <string>
#include <fstream>
#include <iomanip>
#include <vector>
using namespace std;
int main()
{
string fileName,line;
ifstream infile;
cout<<"Enter the file name and complete path: ";
cin>>fileName;
int Aa=0,count=0;
std::vector<string> A;
infile.open(fileName.c_str());
while(!infile.eof())
{
getline(infile,line);
if(line[count]=='A'||line[count]=='a')
{
A.push_back(line);
A[Aa]=line;
Aa++;
const size_t size = A.size();
for(size_t i=0; i<size; ++i)
{
for (size_t j=0; j<size-i-1;j++)
{
if (A[j+1].length() < A[j].length())// ascending order simply changes to <
{
A[j].swap(A[j+1]);
}
}
}
}
}
return 0;
}
What is the "0". And also I did not want to declare a size due to the fact that I don't know what size to expect. Can this be done without declaring a size?
My current one dimensional vector is of type STRING. However, in my two dimensional vector, I would like to have one time as STRING and another as either INT or DOUBLE. Can I have a two dimensional vector with two different types? How do I declare it?