> From what I understand, in C, I would have to type something
>in like: first[strlen(first ) -1] = '\0';
This is how you have to do it. What you could do is create a function like this:
Code:
void RemoveNewLine(char* Line){
Line[strlen(Line)-1] = '\0';
}
//You then can call the function like this
RemoveNewLine(String);
You could also create a pre-processor macro and then call the macro.
If you have some input as a string, you can turn it into a int using atoi and into a float with atof. What I would do is store it as a float or double and then using printf("%g", Variable). This way, if it is an int it will print the int part. If it is a float it will print it as far as there are significant digits.
For example:
Code:
char String[128] = 10.64
float Number = atof(String);
//Do some manipulation with Number
printf("%g\n", Number);
This (without any other manipulation) would output 10.64.
If you wanted to figure out if it was an int or float I would just compare atof and atoi and see if they are the same. If they are then its an int or else its a float.
Hope that helps.
- Sean