rot13 from command line

Hi! and HELP!

Working on an assignment for a class, been going in circles on how to get arguments from the command line and pump them through a rot13. My rot13 works perfectly if a user just types in the text, but I cannot figure out how to pull the arguments in. For example if my arguments are: Glory to Rome!

Thanks.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <cstdlib>
#include <string>
#include <stdio.h>

using namespace std;

int main(int argc, char *argv[])
{
    int nnumber, i, j ;
	for (int i = 1; i < argc; i++)
// here is where I am having trouble with the input, my goal is to get original to = the arguments from the command line
    char original = cin.get() ;
    while (! cin.eof())
    {
        int nnumber(original) ;
        int lcaps, hcaps, llows, hlows ;
        if (nnumber >= 65 && nnumber <= 77)
        {
        lcaps = nnumber + 13 ;
        cout << char(lcaps) ;
        goto bypass ;
        }
        else if (nnumber >=78 && nnumber <=90)
        {
        hcaps = nnumber - 13 ;
        cout << char(hcaps) ;
        goto bypass ;
        }
        else if (nnumber >= 97 && nnumber <= 109)
        {
        llows = nnumber + 13 ;
        cout << char(llows) ;
        goto bypass ;
        }
        else if (nnumber >= 110 && nnumber <= 122)
        {
        hlows = nnumber - 13 ;
        cout << char(hlows) ;
        goto bypass ;
        }
        else if (nnumber != 10)
        {
        cout << char(nnumber) ;
        bypass:
        original = cin.get() ;
        }
        else
        {
        continue ;
        }
    }
    return 0;
}
Command line arguments are passed via the command line, not read with cin.

./yourProgramName 2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>

using namespace std;

int main(int argc, char **argv)
{
   // argc is the number of parameters passed from the command line.
   cout << "Number of arguments: " << argc << endl;
   for(int i = 0; i < argc; ++i)
      cout << "Argument " << i << " is " << argv[i] << endl;

   if(argv[argc] == nullptr)  // If not using a C++11 compiler replace nullptr with 0.
      cout << "argv[" << argc << "] is equal to a nullptr" << std::endl;


   return 0;
}
Makes sense, thanks.
Topic archived. No new replies allowed.