#WSQ09

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;
}

 

Advertisements

One comment on “#WSQ09

  1. 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!

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s