- Jul 20, 2005
- 72
- 0
- 0
basically i am reading lines in of unknown length from a file in the form of a string
I then have to split it up into the following. Number1, Operator, and Number2
The program basically reads in things like the following:
1234 * 23
321 + 42113
352 p 4323
*, +, and p are the only valid operators and the format is always number string, space, operator, space, number string.
I am using unsigned i = str.find(' '); to find the length of the first number string(i - 1), unsigned op = str.find('+*p'); to find the local of the operator. and unsigned k = str.find('/n'); to find the line length.
I then use something like the following:
for(i=num1_len-1 , i=0, i--) Num1= (int)(str-'0');
for(j=oplocal) op= (char)(str[j]);
for(k=linelen, k=num1_len+3, k--) Num2[k]= int(str[k]-'0');
to make the strings into char arrays but im not sure if this is really a correct method at all as I am just getting into strings.
I then have to split it up into the following. Number1, Operator, and Number2
The program basically reads in things like the following:
1234 * 23
321 + 42113
352 p 4323
*, +, and p are the only valid operators and the format is always number string, space, operator, space, number string.
I am using unsigned i = str.find(' '); to find the length of the first number string(i - 1), unsigned op = str.find('+*p'); to find the local of the operator. and unsigned k = str.find('/n'); to find the line length.
I then use something like the following:
for(i=num1_len-1 , i=0, i--) Num1= (int)(str-'0');
for(j=oplocal) op= (char)(str[j]);
for(k=linelen, k=num1_len+3, k--) Num2[k]= int(str[k]-'0');
to make the strings into char arrays but im not sure if this is really a correct method at all as I am just getting into strings.