SlideShare a Scribd company logo
1 of 18
Download to read offline
#include
#include
#include
#include
/*Structure for storing words received from each thread*/
struct return_val{
char wordlist[100][100];
int count[100];
} *arr;
pthread_t *threads;
int lines;
/*Aggregates Frequency Sum of different threads*/
int aggregate(char *a)
{
int sum = 0;
int i=0;
while(1)
{
if(i==lines) break;
int count = 0;
while(1)
{
if(arr[i].count[count] == -1)
{
break;
}
if(strcmp(a,arr[i].wordlist[count]) == 0)
{
sum += arr[i].count[count];
arr[i].count[count] = 0;
}
count++;
}
i++;
}
return sum;
}
/*Function executed by each thread on separate line*/
void *word_count(void* num)
{
int *ln = num;
unsigned int line_number = *ln;
line_number++;
char cmd_p1[9] = "sed -n '0";
char cmd_p2[2];
sprintf(cmd_p2,"%d",line_number);
char cmd_p3[14] = "p' 'file.txt'0";
char command[100];
command[0] = '0';
strcat(command,cmd_p1);
strcat(command,cmd_p2);
strcat(command,cmd_p3);
//usleep(line_number);
char cmd[100] = " | tr [:space:] ' ' | grep -v '^s*$' | sort | uniq -c | sort0";
strcat(command,cmd);
FILE *in;
in= popen(command, "r");
rewind(in);
char buff[50];
int counter = 0;
while(fgets(buff,sizeof(buff),in))
{
char c=' ';
int i = 0;
int cnt = atoi(buff);
arr[line_number-1].count[counter] = cnt;
while(c!='0')
{
c=buff[i];
buff[i]=buff[i+6];
i++;
}
int cnnt = 0;
while(c!=' ')
{
c = buff[cnnt];
cnnt++;
}
i=0;
while(c!='0')
{
c=buff[i];
buff[i]=buff[i+cnnt];
i++;
}
sprintf(arr[line_number-1].wordlist[counter],"%s",buff);
counter++;
}
arr[line_number-1].count[counter] = -1;
fclose(in);
return NULL;
}
int main(void)
{
FILE *fp;
fp = fopen("file.txt","r");
char a[200];
lines = 0;
void *status = NULL;
while(fgets(a,sizeof(a),fp) !=NULL)
{
lines++;
}
fclose(fp);
arr = (struct return_val*) calloc(lines, sizeof(struct return_val) * lines);
threads = malloc(sizeof(pthread_t)*lines);
int i;
for(i=0;i= 0)
{
if(arr[i].count[ctr] > 0)
{
strcpy(final[final_ctr],arr[i].wordlist[ctr]);
final_cnt[final_ctr] = arr[i].count[ctr];
arr[i].count[ctr] = 0;
int sum = aggregate(arr[i].wordlist[ctr]);
final_cnt[final_ctr] += sum;
printf("%d %s",final_cnt[final_ctr],final[final_ctr]);
}
ctr++; final_ctr++;
}
i++;
if(i==lines)
{
break;
}
}
free(arr);
return 0;
}
#include
#include
#include
#include
/*Structure for storing words received from each thread*/
struct return_val{
char wordlist[100][100];
int count[100];
} *arr;
pthread_t *threads;
int lines;
/*Aggregates Frequency Sum of different threads*/
int aggregate(char *a)
{
int sum = 0;
int i=0;
while(1)
{
if(i==lines) break;
int count = 0;
while(1)
{
if(arr[i].count[count] == -1)
{
break;
}
if(strcmp(a,arr[i].wordlist[count]) == 0)
{
sum += arr[i].count[count];
arr[i].count[count] = 0;
}
count++;
}
i++;
}
return sum;
}
/*Function executed by each thread on separate line*/
void *word_count(void* num)
{
int *ln = num;
unsigned int line_number = *ln;
line_number++;
char cmd_p1[9] = "sed -n '0";
char cmd_p2[2];
sprintf(cmd_p2,"%d",line_number);
char cmd_p3[14] = "p' 'file.txt'0";
char command[100];
command[0] = '0';
strcat(command,cmd_p1);
strcat(command,cmd_p2);
strcat(command,cmd_p3);
//usleep(line_number);
char cmd[100] = " | tr [:space:] ' ' | grep -v '^s*$' | sort | uniq -c | sort0";
strcat(command,cmd);
FILE *in;
in= popen(command, "r");
rewind(in);
char buff[50];
int counter = 0;
while(fgets(buff,sizeof(buff),in))
{
char c=' ';
int i = 0;
int cnt = atoi(buff);
arr[line_number-1].count[counter] = cnt;
while(c!='0')
{
c=buff[i];
buff[i]=buff[i+6];
i++;
}
int cnnt = 0;
while(c!=' ')
{
c = buff[cnnt];
cnnt++;
}
i=0;
while(c!='0')
{
c=buff[i];
buff[i]=buff[i+cnnt];
i++;
}
sprintf(arr[line_number-1].wordlist[counter],"%s",buff);
counter++;
}
arr[line_number-1].count[counter] = -1;
fclose(in);
return NULL;
}
int main(void)
{
FILE *fp;
fp = fopen("file.txt","r");
char a[200];
lines = 0;
void *status = NULL;
while(fgets(a,sizeof(a),fp) !=NULL)
{
lines++;
}
fclose(fp);
arr = (struct return_val*) calloc(lines, sizeof(struct return_val) * lines);
threads = malloc(sizeof(pthread_t)*lines);
int i;
for(i=0;i= 0)
{
if(arr[i].count[ctr] > 0)
{
strcpy(final[final_ctr],arr[i].wordlist[ctr]);
final_cnt[final_ctr] = arr[i].count[ctr];
arr[i].count[ctr] = 0;
int sum = aggregate(arr[i].wordlist[ctr]);
final_cnt[final_ctr] += sum;
printf("%d %s",final_cnt[final_ctr],final[final_ctr]);
}
ctr++; final_ctr++;
}
i++;
if(i==lines)
{
break;
}
}
free(arr);
return 0;
}
Solution
#include
#include
#include
#include
/*Structure for storing words received from each thread*/
struct return_val{
char wordlist[100][100];
int count[100];
} *arr;
pthread_t *threads;
int lines;
/*Aggregates Frequency Sum of different threads*/
int aggregate(char *a)
{
int sum = 0;
int i=0;
while(1)
{
if(i==lines) break;
int count = 0;
while(1)
{
if(arr[i].count[count] == -1)
{
break;
}
if(strcmp(a,arr[i].wordlist[count]) == 0)
{
sum += arr[i].count[count];
arr[i].count[count] = 0;
}
count++;
}
i++;
}
return sum;
}
/*Function executed by each thread on separate line*/
void *word_count(void* num)
{
int *ln = num;
unsigned int line_number = *ln;
line_number++;
char cmd_p1[9] = "sed -n '0";
char cmd_p2[2];
sprintf(cmd_p2,"%d",line_number);
char cmd_p3[14] = "p' 'file.txt'0";
char command[100];
command[0] = '0';
strcat(command,cmd_p1);
strcat(command,cmd_p2);
strcat(command,cmd_p3);
//usleep(line_number);
char cmd[100] = " | tr [:space:] ' ' | grep -v '^s*$' | sort | uniq -c | sort0";
strcat(command,cmd);
FILE *in;
in= popen(command, "r");
rewind(in);
char buff[50];
int counter = 0;
while(fgets(buff,sizeof(buff),in))
{
char c=' ';
int i = 0;
int cnt = atoi(buff);
arr[line_number-1].count[counter] = cnt;
while(c!='0')
{
c=buff[i];
buff[i]=buff[i+6];
i++;
}
int cnnt = 0;
while(c!=' ')
{
c = buff[cnnt];
cnnt++;
}
i=0;
while(c!='0')
{
c=buff[i];
buff[i]=buff[i+cnnt];
i++;
}
sprintf(arr[line_number-1].wordlist[counter],"%s",buff);
counter++;
}
arr[line_number-1].count[counter] = -1;
fclose(in);
return NULL;
}
int main(void)
{
FILE *fp;
fp = fopen("file.txt","r");
char a[200];
lines = 0;
void *status = NULL;
while(fgets(a,sizeof(a),fp) !=NULL)
{
lines++;
}
fclose(fp);
arr = (struct return_val*) calloc(lines, sizeof(struct return_val) * lines);
threads = malloc(sizeof(pthread_t)*lines);
int i;
for(i=0;i= 0)
{
if(arr[i].count[ctr] > 0)
{
strcpy(final[final_ctr],arr[i].wordlist[ctr]);
final_cnt[final_ctr] = arr[i].count[ctr];
arr[i].count[ctr] = 0;
int sum = aggregate(arr[i].wordlist[ctr]);
final_cnt[final_ctr] += sum;
printf("%d %s",final_cnt[final_ctr],final[final_ctr]);
}
ctr++; final_ctr++;
}
i++;
if(i==lines)
{
break;
}
}
free(arr);
return 0;
}
#include
#include
#include
#include
/*Structure for storing words received from each thread*/
struct return_val{
char wordlist[100][100];
int count[100];
} *arr;
pthread_t *threads;
int lines;
/*Aggregates Frequency Sum of different threads*/
int aggregate(char *a)
{
int sum = 0;
int i=0;
while(1)
{
if(i==lines) break;
int count = 0;
while(1)
{
if(arr[i].count[count] == -1)
{
break;
}
if(strcmp(a,arr[i].wordlist[count]) == 0)
{
sum += arr[i].count[count];
arr[i].count[count] = 0;
}
count++;
}
i++;
}
return sum;
}
/*Function executed by each thread on separate line*/
void *word_count(void* num)
{
int *ln = num;
unsigned int line_number = *ln;
line_number++;
char cmd_p1[9] = "sed -n '0";
char cmd_p2[2];
sprintf(cmd_p2,"%d",line_number);
char cmd_p3[14] = "p' 'file.txt'0";
char command[100];
command[0] = '0';
strcat(command,cmd_p1);
strcat(command,cmd_p2);
strcat(command,cmd_p3);
//usleep(line_number);
char cmd[100] = " | tr [:space:] ' ' | grep -v '^s*$' | sort | uniq -c | sort0";
strcat(command,cmd);
FILE *in;
in= popen(command, "r");
rewind(in);
char buff[50];
int counter = 0;
while(fgets(buff,sizeof(buff),in))
{
char c=' ';
int i = 0;
int cnt = atoi(buff);
arr[line_number-1].count[counter] = cnt;
while(c!='0')
{
c=buff[i];
buff[i]=buff[i+6];
i++;
}
int cnnt = 0;
while(c!=' ')
{
c = buff[cnnt];
cnnt++;
}
i=0;
while(c!='0')
{
c=buff[i];
buff[i]=buff[i+cnnt];
i++;
}
sprintf(arr[line_number-1].wordlist[counter],"%s",buff);
counter++;
}
arr[line_number-1].count[counter] = -1;
fclose(in);
return NULL;
}
int main(void)
{
FILE *fp;
fp = fopen("file.txt","r");
char a[200];
lines = 0;
void *status = NULL;
while(fgets(a,sizeof(a),fp) !=NULL)
{
lines++;
}
fclose(fp);
arr = (struct return_val*) calloc(lines, sizeof(struct return_val) * lines);
threads = malloc(sizeof(pthread_t)*lines);
int i;
for(i=0;i= 0)
{
if(arr[i].count[ctr] > 0)
{
strcpy(final[final_ctr],arr[i].wordlist[ctr]);
final_cnt[final_ctr] = arr[i].count[ctr];
arr[i].count[ctr] = 0;
int sum = aggregate(arr[i].wordlist[ctr]);
final_cnt[final_ctr] += sum;
printf("%d %s",final_cnt[final_ctr],final[final_ctr]);
}
ctr++; final_ctr++;
}
i++;
if(i==lines)
{
break;
}
}
free(arr);
return 0;
}

More Related Content

Similar to #include stdio.h#include stdlib.h#include string.h#inclu.pdf

1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdfrushabhshah600
 
4 operators, expressions & statements
4  operators, expressions & statements4  operators, expressions & statements
4 operators, expressions & statementsMomenMostafa
 
The following is my code for a connectn program. When I run my code .pdf
The following is my code for a connectn program. When I run my code .pdfThe following is my code for a connectn program. When I run my code .pdf
The following is my code for a connectn program. When I run my code .pdfeyelineoptics
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Er Ritu Aggarwal
 
Program of sorting using shell sort #include stdio.h #de.pdf
 Program of sorting using shell sort  #include stdio.h #de.pdf Program of sorting using shell sort  #include stdio.h #de.pdf
Program of sorting using shell sort #include stdio.h #de.pdfanujmkt
 
Hangman Game Programming in C (coding)
Hangman Game Programming in C (coding)Hangman Game Programming in C (coding)
Hangman Game Programming in C (coding)hasan0812
 
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docxcmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docxgordienaysmythe
 
Data Structure in C Programming Language
Data Structure in C Programming LanguageData Structure in C Programming Language
Data Structure in C Programming LanguageArkadeep Dey
 
Implementing Software Machines in Go and C
Implementing Software Machines in Go and CImplementing Software Machines in Go and C
Implementing Software Machines in Go and CEleanor McHugh
 
VTU DSA Lab Manual
VTU DSA Lab ManualVTU DSA Lab Manual
VTU DSA Lab ManualAkhilaaReddy
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solutionAzhar Javed
 
Imugi: Compiler made with Python
Imugi: Compiler made with PythonImugi: Compiler made with Python
Imugi: Compiler made with PythonHan Lee
 
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docxAdamq0DJonese
 
C programming.   For this code I only need to add a function so th.pdf
C programming.   For this code I only need to add a function so th.pdfC programming.   For this code I only need to add a function so th.pdf
C programming.   For this code I only need to add a function so th.pdfbadshetoms
 
Write a program that obtains the execution time of selection sort, bu.pdf
Write a program that obtains the execution time of selection sort, bu.pdfWrite a program that obtains the execution time of selection sort, bu.pdf
Write a program that obtains the execution time of selection sort, bu.pdfarri2009av
 

Similar to #include stdio.h#include stdlib.h#include string.h#inclu.pdf (20)

1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
 
4 operators, expressions & statements
4  operators, expressions & statements4  operators, expressions & statements
4 operators, expressions & statements
 
The following is my code for a connectn program. When I run my code .pdf
The following is my code for a connectn program. When I run my code .pdfThe following is my code for a connectn program. When I run my code .pdf
The following is my code for a connectn program. When I run my code .pdf
 
C program
C programC program
C program
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02
 
Program of sorting using shell sort #include stdio.h #de.pdf
 Program of sorting using shell sort  #include stdio.h #de.pdf Program of sorting using shell sort  #include stdio.h #de.pdf
Program of sorting using shell sort #include stdio.h #de.pdf
 
Hangman Game Programming in C (coding)
Hangman Game Programming in C (coding)Hangman Game Programming in C (coding)
Hangman Game Programming in C (coding)
 
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docxcmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
cmdfile.txtsleep 5ls -latrsleep 3pwdsleep 1wc .docx
 
Cpds lab
Cpds labCpds lab
Cpds lab
 
week-6x
week-6xweek-6x
week-6x
 
c programming
c programmingc programming
c programming
 
Data Structure in C Programming Language
Data Structure in C Programming LanguageData Structure in C Programming Language
Data Structure in C Programming Language
 
Implementing Software Machines in Go and C
Implementing Software Machines in Go and CImplementing Software Machines in Go and C
Implementing Software Machines in Go and C
 
VTU DSA Lab Manual
VTU DSA Lab ManualVTU DSA Lab Manual
VTU DSA Lab Manual
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
Imugi: Compiler made with Python
Imugi: Compiler made with PythonImugi: Compiler made with Python
Imugi: Compiler made with Python
 
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx
-- Task 2- Debugging a program with stacks- queues- and doubly-linked.docx
 
C programming.   For this code I only need to add a function so th.pdf
C programming.   For this code I only need to add a function so th.pdfC programming.   For this code I only need to add a function so th.pdf
C programming.   For this code I only need to add a function so th.pdf
 
Write a program that obtains the execution time of selection sort, bu.pdf
Write a program that obtains the execution time of selection sort, bu.pdfWrite a program that obtains the execution time of selection sort, bu.pdf
Write a program that obtains the execution time of selection sort, bu.pdf
 

More from apleather

pH = -log[H+] pH = -log(0.5) pH = 0.301 .pdf
                     pH = -log[H+]  pH = -log(0.5)  pH = 0.301        .pdf                     pH = -log[H+]  pH = -log(0.5)  pH = 0.301        .pdf
pH = -log[H+] pH = -log(0.5) pH = 0.301 .pdfapleather
 
The universality of the genetic code provides strong support for the.pdf
The universality of the genetic code provides strong support for the.pdfThe universality of the genetic code provides strong support for the.pdf
The universality of the genetic code provides strong support for the.pdfapleather
 
The pus is consists of neutrophils which target the pathogen. The pa.pdf
The pus is consists of neutrophils which target the pathogen. The pa.pdfThe pus is consists of neutrophils which target the pathogen. The pa.pdf
The pus is consists of neutrophils which target the pathogen. The pa.pdfapleather
 
The least soluble gas is N2 because it is inert and cannot form any .pdf
The least soluble gas is N2 because it is inert and cannot form any .pdfThe least soluble gas is N2 because it is inert and cannot form any .pdf
The least soluble gas is N2 because it is inert and cannot form any .pdfapleather
 
The below stated are the Challenges and business requirements faced .pdf
The below stated are the Challenges and business requirements faced .pdfThe below stated are the Challenges and business requirements faced .pdf
The below stated are the Challenges and business requirements faced .pdfapleather
 
Sometimes CEO can also hold the position of Chairperson, but in some.pdf
Sometimes CEO can also hold the position of Chairperson, but in some.pdfSometimes CEO can also hold the position of Chairperson, but in some.pdf
Sometimes CEO can also hold the position of Chairperson, but in some.pdfapleather
 
SolutionInorder traversal It will consider left child root, and .pdf
SolutionInorder traversal It will consider left child root, and .pdfSolutionInorder traversal It will consider left child root, and .pdf
SolutionInorder traversal It will consider left child root, and .pdfapleather
 
In a side the length of sides are same. use this property iterativel.pdf
In a side the length of sides are same. use this property iterativel.pdfIn a side the length of sides are same. use this property iterativel.pdf
In a side the length of sides are same. use this property iterativel.pdfapleather
 
Elements or steps of acceptance testingSolutionElements or ste.pdf
Elements or steps of acceptance testingSolutionElements or ste.pdfElements or steps of acceptance testingSolutionElements or ste.pdf
Elements or steps of acceptance testingSolutionElements or ste.pdfapleather
 
Long term capital = Common stock + shareholders equity + Retained ea.pdf
Long term capital = Common stock + shareholders equity + Retained ea.pdfLong term capital = Common stock + shareholders equity + Retained ea.pdf
Long term capital = Common stock + shareholders equity + Retained ea.pdfapleather
 
Limbs evolve so frequently that it is impossible to determine otherw.pdf
Limbs evolve so frequently that it is impossible to determine otherw.pdfLimbs evolve so frequently that it is impossible to determine otherw.pdf
Limbs evolve so frequently that it is impossible to determine otherw.pdfapleather
 
hmmSolutionhmm.pdf
hmmSolutionhmm.pdfhmmSolutionhmm.pdf
hmmSolutionhmm.pdfapleather
 
Form1.csusing System; using System.Collections.Generic; using .pdf
Form1.csusing System; using System.Collections.Generic; using .pdfForm1.csusing System; using System.Collections.Generic; using .pdf
Form1.csusing System; using System.Collections.Generic; using .pdfapleather
 
Influenza A The recently raised awareness of th.pdf
                     Influenza A  The recently raised awareness of th.pdf                     Influenza A  The recently raised awareness of th.pdf
Influenza A The recently raised awareness of th.pdfapleather
 
I believe its named Methyl iodide. You wouldn.pdf
                     I believe its named Methyl iodide. You wouldn.pdf                     I believe its named Methyl iodide. You wouldn.pdf
I believe its named Methyl iodide. You wouldn.pdfapleather
 
Data warehousing has quickly evolved into a unique and popular busin.pdf
Data warehousing has quickly evolved into a unique and popular busin.pdfData warehousing has quickly evolved into a unique and popular busin.pdf
Data warehousing has quickly evolved into a unique and popular busin.pdfapleather
 
balready postedSolutionbalready posted.pdf
balready postedSolutionbalready posted.pdfbalready postedSolutionbalready posted.pdf
balready postedSolutionbalready posted.pdfapleather
 
Assume the graph is strongly connected.SolutionAssume the grap.pdf
Assume the graph is strongly connected.SolutionAssume the grap.pdfAssume the graph is strongly connected.SolutionAssume the grap.pdf
Assume the graph is strongly connected.SolutionAssume the grap.pdfapleather
 
Half life is the time in which the compound reduc.pdf
                     Half life is the time in which the compound reduc.pdf                     Half life is the time in which the compound reduc.pdf
Half life is the time in which the compound reduc.pdfapleather
 
from the given reaction, order NO3=1 overall orde.pdf
                     from the given reaction, order NO3=1 overall orde.pdf                     from the given reaction, order NO3=1 overall orde.pdf
from the given reaction, order NO3=1 overall orde.pdfapleather
 

More from apleather (20)

pH = -log[H+] pH = -log(0.5) pH = 0.301 .pdf
                     pH = -log[H+]  pH = -log(0.5)  pH = 0.301        .pdf                     pH = -log[H+]  pH = -log(0.5)  pH = 0.301        .pdf
pH = -log[H+] pH = -log(0.5) pH = 0.301 .pdf
 
The universality of the genetic code provides strong support for the.pdf
The universality of the genetic code provides strong support for the.pdfThe universality of the genetic code provides strong support for the.pdf
The universality of the genetic code provides strong support for the.pdf
 
The pus is consists of neutrophils which target the pathogen. The pa.pdf
The pus is consists of neutrophils which target the pathogen. The pa.pdfThe pus is consists of neutrophils which target the pathogen. The pa.pdf
The pus is consists of neutrophils which target the pathogen. The pa.pdf
 
The least soluble gas is N2 because it is inert and cannot form any .pdf
The least soluble gas is N2 because it is inert and cannot form any .pdfThe least soluble gas is N2 because it is inert and cannot form any .pdf
The least soluble gas is N2 because it is inert and cannot form any .pdf
 
The below stated are the Challenges and business requirements faced .pdf
The below stated are the Challenges and business requirements faced .pdfThe below stated are the Challenges and business requirements faced .pdf
The below stated are the Challenges and business requirements faced .pdf
 
Sometimes CEO can also hold the position of Chairperson, but in some.pdf
Sometimes CEO can also hold the position of Chairperson, but in some.pdfSometimes CEO can also hold the position of Chairperson, but in some.pdf
Sometimes CEO can also hold the position of Chairperson, but in some.pdf
 
SolutionInorder traversal It will consider left child root, and .pdf
SolutionInorder traversal It will consider left child root, and .pdfSolutionInorder traversal It will consider left child root, and .pdf
SolutionInorder traversal It will consider left child root, and .pdf
 
In a side the length of sides are same. use this property iterativel.pdf
In a side the length of sides are same. use this property iterativel.pdfIn a side the length of sides are same. use this property iterativel.pdf
In a side the length of sides are same. use this property iterativel.pdf
 
Elements or steps of acceptance testingSolutionElements or ste.pdf
Elements or steps of acceptance testingSolutionElements or ste.pdfElements or steps of acceptance testingSolutionElements or ste.pdf
Elements or steps of acceptance testingSolutionElements or ste.pdf
 
Long term capital = Common stock + shareholders equity + Retained ea.pdf
Long term capital = Common stock + shareholders equity + Retained ea.pdfLong term capital = Common stock + shareholders equity + Retained ea.pdf
Long term capital = Common stock + shareholders equity + Retained ea.pdf
 
Limbs evolve so frequently that it is impossible to determine otherw.pdf
Limbs evolve so frequently that it is impossible to determine otherw.pdfLimbs evolve so frequently that it is impossible to determine otherw.pdf
Limbs evolve so frequently that it is impossible to determine otherw.pdf
 
hmmSolutionhmm.pdf
hmmSolutionhmm.pdfhmmSolutionhmm.pdf
hmmSolutionhmm.pdf
 
Form1.csusing System; using System.Collections.Generic; using .pdf
Form1.csusing System; using System.Collections.Generic; using .pdfForm1.csusing System; using System.Collections.Generic; using .pdf
Form1.csusing System; using System.Collections.Generic; using .pdf
 
Influenza A The recently raised awareness of th.pdf
                     Influenza A  The recently raised awareness of th.pdf                     Influenza A  The recently raised awareness of th.pdf
Influenza A The recently raised awareness of th.pdf
 
I believe its named Methyl iodide. You wouldn.pdf
                     I believe its named Methyl iodide. You wouldn.pdf                     I believe its named Methyl iodide. You wouldn.pdf
I believe its named Methyl iodide. You wouldn.pdf
 
Data warehousing has quickly evolved into a unique and popular busin.pdf
Data warehousing has quickly evolved into a unique and popular busin.pdfData warehousing has quickly evolved into a unique and popular busin.pdf
Data warehousing has quickly evolved into a unique and popular busin.pdf
 
balready postedSolutionbalready posted.pdf
balready postedSolutionbalready posted.pdfbalready postedSolutionbalready posted.pdf
balready postedSolutionbalready posted.pdf
 
Assume the graph is strongly connected.SolutionAssume the grap.pdf
Assume the graph is strongly connected.SolutionAssume the grap.pdfAssume the graph is strongly connected.SolutionAssume the grap.pdf
Assume the graph is strongly connected.SolutionAssume the grap.pdf
 
Half life is the time in which the compound reduc.pdf
                     Half life is the time in which the compound reduc.pdf                     Half life is the time in which the compound reduc.pdf
Half life is the time in which the compound reduc.pdf
 
from the given reaction, order NO3=1 overall orde.pdf
                     from the given reaction, order NO3=1 overall orde.pdf                     from the given reaction, order NO3=1 overall orde.pdf
from the given reaction, order NO3=1 overall orde.pdf
 

Recently uploaded

Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 

Recently uploaded (20)

Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 

#include stdio.h#include stdlib.h#include string.h#inclu.pdf

  • 1. #include #include #include #include /*Structure for storing words received from each thread*/ struct return_val{ char wordlist[100][100]; int count[100]; } *arr; pthread_t *threads; int lines; /*Aggregates Frequency Sum of different threads*/ int aggregate(char *a) { int sum = 0; int i=0; while(1) { if(i==lines) break; int count = 0; while(1) { if(arr[i].count[count] == -1) { break; } if(strcmp(a,arr[i].wordlist[count]) == 0) { sum += arr[i].count[count]; arr[i].count[count] = 0; } count++;
  • 2. } i++; } return sum; } /*Function executed by each thread on separate line*/ void *word_count(void* num) { int *ln = num; unsigned int line_number = *ln; line_number++; char cmd_p1[9] = "sed -n '0"; char cmd_p2[2]; sprintf(cmd_p2,"%d",line_number); char cmd_p3[14] = "p' 'file.txt'0"; char command[100]; command[0] = '0'; strcat(command,cmd_p1); strcat(command,cmd_p2); strcat(command,cmd_p3); //usleep(line_number); char cmd[100] = " | tr [:space:] ' ' | grep -v '^s*$' | sort | uniq -c | sort0"; strcat(command,cmd); FILE *in; in= popen(command, "r"); rewind(in); char buff[50]; int counter = 0; while(fgets(buff,sizeof(buff),in))
  • 3. { char c=' '; int i = 0; int cnt = atoi(buff); arr[line_number-1].count[counter] = cnt; while(c!='0') { c=buff[i]; buff[i]=buff[i+6]; i++; } int cnnt = 0; while(c!=' ') { c = buff[cnnt]; cnnt++; } i=0; while(c!='0') { c=buff[i]; buff[i]=buff[i+cnnt]; i++; } sprintf(arr[line_number-1].wordlist[counter],"%s",buff); counter++; } arr[line_number-1].count[counter] = -1; fclose(in); return NULL;
  • 4. } int main(void) { FILE *fp; fp = fopen("file.txt","r"); char a[200]; lines = 0; void *status = NULL; while(fgets(a,sizeof(a),fp) !=NULL) { lines++; } fclose(fp); arr = (struct return_val*) calloc(lines, sizeof(struct return_val) * lines); threads = malloc(sizeof(pthread_t)*lines); int i; for(i=0;i= 0) { if(arr[i].count[ctr] > 0) { strcpy(final[final_ctr],arr[i].wordlist[ctr]); final_cnt[final_ctr] = arr[i].count[ctr]; arr[i].count[ctr] = 0; int sum = aggregate(arr[i].wordlist[ctr]); final_cnt[final_ctr] += sum; printf("%d %s",final_cnt[final_ctr],final[final_ctr]); } ctr++; final_ctr++; }
  • 5. i++; if(i==lines) { break; } } free(arr); return 0; } #include #include #include #include /*Structure for storing words received from each thread*/ struct return_val{ char wordlist[100][100]; int count[100]; } *arr; pthread_t *threads; int lines; /*Aggregates Frequency Sum of different threads*/ int aggregate(char *a) { int sum = 0; int i=0; while(1) { if(i==lines) break; int count = 0; while(1) { if(arr[i].count[count] == -1) { break; }
  • 6. if(strcmp(a,arr[i].wordlist[count]) == 0) { sum += arr[i].count[count]; arr[i].count[count] = 0; } count++; } i++; } return sum; } /*Function executed by each thread on separate line*/ void *word_count(void* num) { int *ln = num; unsigned int line_number = *ln; line_number++; char cmd_p1[9] = "sed -n '0"; char cmd_p2[2]; sprintf(cmd_p2,"%d",line_number); char cmd_p3[14] = "p' 'file.txt'0"; char command[100]; command[0] = '0'; strcat(command,cmd_p1); strcat(command,cmd_p2); strcat(command,cmd_p3); //usleep(line_number);
  • 7. char cmd[100] = " | tr [:space:] ' ' | grep -v '^s*$' | sort | uniq -c | sort0"; strcat(command,cmd); FILE *in; in= popen(command, "r"); rewind(in); char buff[50]; int counter = 0; while(fgets(buff,sizeof(buff),in)) { char c=' '; int i = 0; int cnt = atoi(buff); arr[line_number-1].count[counter] = cnt; while(c!='0') { c=buff[i]; buff[i]=buff[i+6]; i++; } int cnnt = 0; while(c!=' ') { c = buff[cnnt]; cnnt++; } i=0; while(c!='0') { c=buff[i]; buff[i]=buff[i+cnnt]; i++; }
  • 8. sprintf(arr[line_number-1].wordlist[counter],"%s",buff); counter++; } arr[line_number-1].count[counter] = -1; fclose(in); return NULL; } int main(void) { FILE *fp; fp = fopen("file.txt","r"); char a[200]; lines = 0; void *status = NULL; while(fgets(a,sizeof(a),fp) !=NULL) { lines++; } fclose(fp); arr = (struct return_val*) calloc(lines, sizeof(struct return_val) * lines); threads = malloc(sizeof(pthread_t)*lines); int i; for(i=0;i= 0) { if(arr[i].count[ctr] > 0) { strcpy(final[final_ctr],arr[i].wordlist[ctr]); final_cnt[final_ctr] = arr[i].count[ctr];
  • 9. arr[i].count[ctr] = 0; int sum = aggregate(arr[i].wordlist[ctr]); final_cnt[final_ctr] += sum; printf("%d %s",final_cnt[final_ctr],final[final_ctr]); } ctr++; final_ctr++; } i++; if(i==lines) { break; } } free(arr); return 0; } Solution #include #include #include #include /*Structure for storing words received from each thread*/ struct return_val{ char wordlist[100][100]; int count[100]; } *arr; pthread_t *threads; int lines; /*Aggregates Frequency Sum of different threads*/ int aggregate(char *a) {
  • 10. int sum = 0; int i=0; while(1) { if(i==lines) break; int count = 0; while(1) { if(arr[i].count[count] == -1) { break; } if(strcmp(a,arr[i].wordlist[count]) == 0) { sum += arr[i].count[count]; arr[i].count[count] = 0; } count++; } i++; } return sum; } /*Function executed by each thread on separate line*/ void *word_count(void* num) { int *ln = num; unsigned int line_number = *ln;
  • 11. line_number++; char cmd_p1[9] = "sed -n '0"; char cmd_p2[2]; sprintf(cmd_p2,"%d",line_number); char cmd_p3[14] = "p' 'file.txt'0"; char command[100]; command[0] = '0'; strcat(command,cmd_p1); strcat(command,cmd_p2); strcat(command,cmd_p3); //usleep(line_number); char cmd[100] = " | tr [:space:] ' ' | grep -v '^s*$' | sort | uniq -c | sort0"; strcat(command,cmd); FILE *in; in= popen(command, "r"); rewind(in); char buff[50]; int counter = 0; while(fgets(buff,sizeof(buff),in)) { char c=' '; int i = 0; int cnt = atoi(buff); arr[line_number-1].count[counter] = cnt; while(c!='0') { c=buff[i]; buff[i]=buff[i+6]; i++; } int cnnt = 0;
  • 12. while(c!=' ') { c = buff[cnnt]; cnnt++; } i=0; while(c!='0') { c=buff[i]; buff[i]=buff[i+cnnt]; i++; } sprintf(arr[line_number-1].wordlist[counter],"%s",buff); counter++; } arr[line_number-1].count[counter] = -1; fclose(in); return NULL; } int main(void) { FILE *fp; fp = fopen("file.txt","r"); char a[200]; lines = 0; void *status = NULL; while(fgets(a,sizeof(a),fp) !=NULL) { lines++; }
  • 13. fclose(fp); arr = (struct return_val*) calloc(lines, sizeof(struct return_val) * lines); threads = malloc(sizeof(pthread_t)*lines); int i; for(i=0;i= 0) { if(arr[i].count[ctr] > 0) { strcpy(final[final_ctr],arr[i].wordlist[ctr]); final_cnt[final_ctr] = arr[i].count[ctr]; arr[i].count[ctr] = 0; int sum = aggregate(arr[i].wordlist[ctr]); final_cnt[final_ctr] += sum; printf("%d %s",final_cnt[final_ctr],final[final_ctr]); } ctr++; final_ctr++; } i++; if(i==lines) { break; } } free(arr); return 0; } #include #include #include #include /*Structure for storing words received from each thread*/
  • 14. struct return_val{ char wordlist[100][100]; int count[100]; } *arr; pthread_t *threads; int lines; /*Aggregates Frequency Sum of different threads*/ int aggregate(char *a) { int sum = 0; int i=0; while(1) { if(i==lines) break; int count = 0; while(1) { if(arr[i].count[count] == -1) { break; } if(strcmp(a,arr[i].wordlist[count]) == 0) { sum += arr[i].count[count]; arr[i].count[count] = 0; } count++; } i++; }
  • 15. return sum; } /*Function executed by each thread on separate line*/ void *word_count(void* num) { int *ln = num; unsigned int line_number = *ln; line_number++; char cmd_p1[9] = "sed -n '0"; char cmd_p2[2]; sprintf(cmd_p2,"%d",line_number); char cmd_p3[14] = "p' 'file.txt'0"; char command[100]; command[0] = '0'; strcat(command,cmd_p1); strcat(command,cmd_p2); strcat(command,cmd_p3); //usleep(line_number); char cmd[100] = " | tr [:space:] ' ' | grep -v '^s*$' | sort | uniq -c | sort0"; strcat(command,cmd); FILE *in; in= popen(command, "r"); rewind(in); char buff[50]; int counter = 0; while(fgets(buff,sizeof(buff),in)) { char c=' '; int i = 0; int cnt = atoi(buff); arr[line_number-1].count[counter] = cnt;
  • 16. while(c!='0') { c=buff[i]; buff[i]=buff[i+6]; i++; } int cnnt = 0; while(c!=' ') { c = buff[cnnt]; cnnt++; } i=0; while(c!='0') { c=buff[i]; buff[i]=buff[i+cnnt]; i++; } sprintf(arr[line_number-1].wordlist[counter],"%s",buff); counter++; } arr[line_number-1].count[counter] = -1; fclose(in); return NULL; } int main(void) { FILE *fp; fp = fopen("file.txt","r");
  • 17. char a[200]; lines = 0; void *status = NULL; while(fgets(a,sizeof(a),fp) !=NULL) { lines++; } fclose(fp); arr = (struct return_val*) calloc(lines, sizeof(struct return_val) * lines); threads = malloc(sizeof(pthread_t)*lines); int i; for(i=0;i= 0) { if(arr[i].count[ctr] > 0) { strcpy(final[final_ctr],arr[i].wordlist[ctr]); final_cnt[final_ctr] = arr[i].count[ctr]; arr[i].count[ctr] = 0; int sum = aggregate(arr[i].wordlist[ctr]); final_cnt[final_ctr] += sum; printf("%d %s",final_cnt[final_ctr],final[final_ctr]); } ctr++; final_ctr++; } i++; if(i==lines) { break; } }