Your parameter is an array of pointers, not a string. The type of side1 should be char*, not char*[].
void checkTriangle(char *side1, /* ... */)
{
/* ... */
}
To handle floating points values, you can check the format of the string.
#include <ctype.h>
#include <stddef.h>
int checkTriangle(const char *s, size_t n)
{
size_t i;
int p1 = 1;
for (i = 0; i < n; ++i) {
if (s[i] == '.')
p1 = 0;
else if (!isdigit(s[i]) && !p1)
return 0;
}
return 1;
}
BTW, your function is not very well designed. You should rather print in the caller and be independant from the string's size.
#include <ctype.h>
#include <stdio.h>
#include <string.h>
int checkTriangle(const char *s, size_t n)
{
size_t i;
for (i = 0; i < n; ++i)
if (!isdigit(s[i]))
return 0;
return 1;
}
int main(void)
{
char s[32];
size_t n;
fgets(s, sizeof s, stdin);
n = strlen(s) - 1;
s[n] = '\0';
if (!checkTriangle(s, n))
puts("You entered string");
return 0;
}
If you are allowed to use the standard C library entirely, can also use strtod.