1. arry/character handling

howdy,
this is what im trying to do:
given this type of input - 25'-5.5" (how ever this input may contain less 3'-6" or more 125'-5.75" characters)
i want to
remove all none digit characters
multiply the figure before the dash by 12 - in this case 25 * 12
add it to the figure after the dash - in this case 5.5
so the answer in this case would be 305.5
with this code i get as far as this:
i can strip the non didgit stuff so i get 25 5.5
i can atof the first figure and multiply it by 12 so i get x=300
what i cant figure out is how to isolate the 5.5 so i can atof it - so now y always equals zero.

this is where im at-------
Code:
```#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <ctype.h>

using namespace std;

int main()
{
double x=0;
double y=0;
int j=0;
system("clear");
char input[20];
cout<<"Enter dimension: ";
cin>>input;
for(int i = 0; i<strlen(input); i++)
if(input[i]=='-' || input[i]=='\''|| input[i]=='"'){
cout<<"Found it @: "<<i<<" position\n";
input[i]= ' ';
}

cout<<"\nAfter processing input = "<<input<<"\n";
x=atof(input);
cout<<strlen(input)<<endl;

cout<<"X = "<<x * 12<<" inches"<<endl;
cout<<"Y = "<<(y)<<endl;

return 0;
}```
all i really want is a concept of how to do it - im trying to learn this stuff so someone else writing the code might not be as good of lesson.

2. Code:
```int feetcount=0;//num of digits in num of feet
while (input[feetcount] != ' ')  feetcount++;

int numoffeet=0;
for ( int x=feetcount; x>=1; x--)  numoffeet+=atoi(input[x])*pow(10,x-1);```
Do this for both. If this doesn't work, sorry, I threw this together quickly b/c I have to go to bed, very tired .

3. howdy,
thanks for the try golfinguy4 i messed with it a bit and i still get the same error i have been running into
rdash.cpp:32: cannot convert `char' to `const char *' for argument `1'
to `atoi (const char *)'
in reference to this line:
Code:
`for ( int x=feetcount; x>=1; x--)  numoffeet+=atoi(input[x])*pow(10,x-1);`
oh well i'll keep trying

M.R.

4. rdash.cpp:32: cannot convert `char' to `const char *' for argument `1'
to `atoi (const char *)'

atoi takes in a string (char*) as input.. you are passing it a char.. i'm tired too (it seems to be a trend on this post) but just make sure you pass it the whole character array, not just one character

5. atoi takes a char * as its argument, so if you are passing a single char you need to pass the address:
Code:
```for ( int x=feetcount; x>=1; x--)
numoffeet += atoi(&input[x]) * pow(10,x-1);```
-Prelude

6. once you get

25 5.5

parse that string into two substrings using strtok() or a homegrown version. then call atoi() or atof() on first string and atof() on second string. Then add the two pieces together into a float (or double).

[code]
char time[20] = "25'-5.5"";
char sHours[6];
char sSmin[10];
float hours;
float min;
int count = 0;
int j = 0;

for(i = 0; i < strlen(time); i++)
{
if(count == 0)
{
if(time[i] != ' ')
sHours[j++] = time[i];
else if(time[i] == ' ')
{
sHours[j] = '\0';
count = 1;
j = 0;
}
else if(count == 1)
sMin[j++] = time[i];
}
sMin[j] = '\0';

hours = atof(sHours);
min = atof(sMin);