Hi to all,
I have done the following code:
#include<stdio.h>
#include<string.h>
#include<ctype.h>
void decodeMorse(char *tokenPointer, char *plainText){
if((strcmp(tokenPointer,".-"))==0)
plainText="A";
if((strcmp(tokenPointer,"-..."))==0)
plainText="B";
}
void main(){
char inputStr[256];
char outputStr[256];
char *tokenPointer;
char *token=NULL;
int c;
int i=0;
while((c=getchar())!=EOF)
inputStr[i++]=c;
inputStr[i]='\0';
tokenPointer=strtok(inputStr," ");
/* we may have to include the following statements here too :
decodeMorse(tokenPointer,token);
strcat(outputStr, token); */ /* not really sure ****/
/*any suggestion??? ****/
while(tokenPointer != NULL){
strcat(outputStr, " ");
decodeMorse(tokenPointer,token);
strcat(outputStr, token);
tokenPointer=strtok(NULL, " ");
}
printf("%s\n",outputStr);
getchar();
}
In my system, I can compile this, but when I run it results exception.
Any pointers would be highly appreciated.
Damar