Command line arguments | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Command line arguments

Can anyone please WAP that prints a table indicating the number of occurences of each alphabet in the text entered as command line arguments in c++

14th Nov 2017, 4:49 PM
Atl∆s Grey
Atl∆s Grey - avatar
3 Answers
+ 4
What will you do with that?
14th Nov 2017, 9:50 PM
Manual
Manual - avatar
0
#include<iostream> #include<string.h> using namespace std; int main(int argc,char *argv[]) { int i; int count=0; cout<<"\nParameters are\n"; for(int i=0;i<argc;i++) cout<<argv[i]<<" "; for(char k='a';k<='z';k++) { for(i=0;i<argc;i++) { for(int j=0;argv[i][j]!='\0';j++) { if(isupper(argv[i][j])) argv[i][j]=tolower(argv[i][j]); if(argv[i][j]==k) count++; } } if(count>0) cout<<"\n"<<k<<" occurs "<<count<<" times."; count=0; } cout<<"\nEnd"; return 0; } If you are using Dev C++,then you will have to pass arguments using parameters in Execute option.
16th Nov 2017, 6:31 PM
Ràjbir Siñgh Chäuháñ
Ràjbir Siñgh Chäuháñ - avatar
0
yeah thank you
16th Nov 2017, 6:37 PM
Atl∆s Grey
Atl∆s Grey - avatar