+ 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++
3 Respuestas
+ 4
What will you do with that?
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.
0
yeah thank you