reading code from user

Hi I have written this program which creates a 6 character string that is a counter that is alpha numeric ranging from 0-9 and then goes to A-Z excluding the characters I and O, but the way I have coded it I have to hard code each character in the program. I would like to change this to where the user can enter a single string for this, and also a string for the number of codes they want to create? I tried doing simple cin and cout commands, but I didn't know if the the overriding of the stream I am using at the end to write my file interferes with that or if its something else, but if anyone could help me in converting this to user inputted information that would be great.
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// basic file operations
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <string>
using namespace std;




int main () {
int n = 1;
string barcode;
char c1='0';
char c2='0';
char c3='0';
char c4='0';
char c5='0';
char c6='0';
string temp;


while(n<=5000)
{if(c6 =='9')
       c6='A';
else
if(c6 =='H')
c6='J';
else
if(c6 =='N')
c6='P';
else
if(c6 == 'Z')
   {c6='0';
        if(c5 =='9')
        c5='A';
        else
        if(c5 =='H')
        c5='J';
        else
        if(c5 =='N')
        c5='P';
        else
        if(c5 == 'Z')
        {c5='0';
              if(c4 =='9')
              c4='A';
              else
               if(c4 =='H')
               c4='J';
               else
               if(c4 =='N')
               c4='P';
               else
              if(c4 == 'Z')
              {c4='0';
                    if(c3 =='9')
                    c3='A';
                    else
                    if(c3 =='H')
                    c3='J';
                    else
                    if(c3 =='N')
                    c3='P';
                    else
                    if(c3 == 'Z')
                    {c3='0';
                          if(c2 =='9')
                          c2='A';
                          else
                          if(c2 =='H')
                          c2='J';
                          else
                          if(c2 =='N')
                          c2='P';
                          else
                          if(c2 == 'Z')
                          {c2='0';
                                if(c1 =='9')
                                c1='A';
                                else
                                if(c1 =='H')
                                c1='J';
                                else
                                if(c1 =='N')
                                c1='P';
                                else
                                if(c1 == 'Z')
                                c1='0';
                                else
                                c1 = ((unsigned int)c1+1);}
                          else
                          c2 = ((unsigned int)c2+1);}
                    else
                    c3 = ((unsigned int)c3+1);}
              else
              c4 = ((unsigned int)c4+1);}
        else
        c5 = ((unsigned int)c5+1);}
else
   c6 = ((unsigned int)c6+1);
   
       

  freopen ("newbarcode.txt","a",stdout);
  cout << c1<< c2<< c3 << c4 << c5 << c6 <<endl;
  fclose (stdout);
  n++;
  }
  
   return 0;
}
Last edited on
yikes posting this removed all of my spacing... How do I post it and make it look like it did in my compiler so its easier for everyone else to read?
closed account (z05DSL3A)
use code tags [code]your code[/code]
Use the <> button on the Right (or maybe bottom.) You can also use [/code] & [code] ([code] for opening and the other for closing.)
thanks guys :-) now my program is at least readable
Topic archived. No new replies allowed.