Quote (Xarai @ Feb 12 2013 02:28pm)
this is how it looks when it's in the program so what do u mean? give an example cause now im lost
Code
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#define true 0
#define false 1
_Bool isString(char *dataArray);
int main()
{
char stringArray[50];
char *morseArray[27] = {".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.."};
int i = 0;
printf("Please insert a string.\n");
fgets(stringArray, 49, stdin);
if(isString(stringArray) == true)
{
//printf("This is a string.\n");
while(stringArray[i] != '\0')
{
if(morseArray[(int)toupper(stringArray[i]) - (int)'A'] != '\0')
{
printf("%s ", morseArray[(int)toupper(stringArray[i]) - (int)'A']);
}
i++;
}
}
else
{
printf("This is not a string.\n");
}
getchar();
return 0;
}
_Bool isString(char *dataArray)
{
for(int i = 0; i < sizeof(dataArray) - 1; i++)
{
if((int)dataArray[i] < 65 || (int)dataArray[i] > 90)
{
return false;
}
}
return true;
}
this is how code looks inside the forums [code] tags
it keeps its indentation and is easier to read because of a font change.