Hi guys! I just finished the video for WSQ09, the link and the code are bellow. A brief explanation: this WSQ is about Multipart data and Files. This program opens a text file and tells you the number of characters and files in it. Enjoy and thanks in advance for watching.
And the code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
struct charlines
{
int chars, lines;
};
charlines countCharLines(charlines & num)
{
string line;
num.lines=0;
num.chars=0;
ifstream file(“data.txt”);
if(file.is_open())
{
while(getline(file, line))
{
num.lines ++;
num.chars += line.size();
}
file.close();
}
return num;
}
int main()
{
charlines number;
countCharLines(number);
cout<<“File chars: “<<number.chars<<endl;
cout<<“File lines: “<<number.lines<<endl;
return 0;
}
Quando alguém escreve um parte de escrita He/she mantém
o pensei de um usuário em sua mente que como um usuário pode
sabe . Portanto é por isso que este n é outstdanding.
Obrigado!
LikeLike