so this part of the code for mylanguage translator basically, i just started coding tokenzing function.
the problem: if i put the tokenize function directly into the main or edit the tokenize function so it'll be the main and run it.. it seems to do it's job. But, if i encorporate that function inside the menu function which is called by main... the tokenize function kinda misfires and doesn't correctly displays what it suppose to display. (i'm guessing pointers and all those asterisks.... or if not what?)
PLEASE HELP.. thanks
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
typedef char string100[101];
typedef char string50[50];
struct nodeTag{
char strInput[31];
char strOutput[100][31];
struct nodeTag *pNext;
};
typedef struct nodeTag *ptrNode;
void Exit();
void Menu();
void Tokenize(ptrNode pStart);
main()
{
Menu();
}
void Exit()
{
clrscr();
}
void Menu(ptrNode pStart)
{
int nSelect, n=1;
char cDump;
do{
clrscr();
puts("\t\t\t ___________");
puts("\t\t\t ( MAIN MENU )\n");
printf("\t\t\t --------------------------\n");
puts(" \t\t\t | SENTENCE TRANSLATOR |");
printf("\t\t\t --------------------------\n");
puts("\t\t\t [1] TOKENIZE ");
puts("\t\t\t [2] ALTERNATE");
printf(" \t\t\t --------------------------\n");
puts("\t\t\t | WORD MANIPULATOR |");
printf(" \t\t\t --------------------------\n");
puts("\t\t\t [3] ADD WORD ");puts("\t\t\t [4] ADD CO-OCCURRING");
puts("\t\t\t [5] DELETE WORD");puts("\t\t\t [6] DELETE CO-OCCURING");
puts("\t\t\t [7] VIEW WORDS");puts("\t\t\t [8] SEARCH WORDS");
puts("\t\t\t [9] EXPORT");puts("\t\t\t [10] IMPORT");
puts("\t\t\t [11] EXIT\n\n");printf("\t\t\t ENTER CHOICE:");
scanf("%d%c",&nSelect,&cDump);
if (nSelect==1){
clrscr();
n=0;
Tokenize(pStart);
}
else if (nSelect==2){
clrscr();
puts("alt");
n=0;
}
else if (nSelect==3){
clrscr();
puts("add");
n=0;
}
else if (nSelect==4){
clrscr();
puts("addc");
n=0;
}
else if (nSelect==5){
clrscr();
puts("del");
n=0;
}
else if (nSelect==6){
clrscr();
puts("delc");
n=0;
}
else if (nSelect==7){
clrscr();
puts("view");
n=0;
}
else if (nSelect==8){
clrscr();
puts("seearch");
n=0;
}
else if (nSelect==9){
Exit();
n=0;
}
else if (nSelect==10){
clrscr();
puts("import");
n=0;
}
else if (nSelect==11){
n=0;
Exit();
}
else{
clrscr();
puts("\t\t\t ___________");
puts("\t\t\t ( MAIN MENU )\n");
printf("\t\t\t --------------------------\n");
puts(" \t\t\t | SENTENCE TRANSLATOR |");
printf("\t\t\t --------------------------\n");
puts("\t\t\t [1] TOKENIZE ");
puts("\t\t\t [2] ALTERNATE");
printf(" \t\t\t --------------------------\n");
puts("\t\t\t | WORD MANIPULATOR |");
printf(" \t\t\t --------------------------\n");
puts("\t\t\t [3] ADD WORD ");puts("\t\t\t [4] ADD CO-OCCURRING");
puts("\t\t\t [5] DELETE WORD");puts("\t\t\t [6] DELETE CO-OCCURING");
puts("\t\t\t [7] VIEW WORDS");puts("\t\t\t [8] SEARCH WORDS");
puts("\t\t\t [9] EXPORT");puts("\t\t\t [10] IMPORT");
puts("\t\t\t [11] EXIT\n\n");printf("\t\t\t ENTER CHOICE:");
scanf("%d",&nSelect);
}
} while (n!=0);
}
void Tokenize(ptrNode pStart)
{
int i=0,sLen;
int x=0,y=0,z=0;
printf("ENTER TEXT: ");
gets(pStart->strInput);
sLen=strlen(pStart->strInput);
while(i <= sLen && pStart->strInput[x]!= '.')
{
if(pStart->strInput[x]!=' ')
{
pStart->strOutput[y][z] = pStart->strInput[x];
printf("%c",pStart->strOutput[y][z]);
z++;
}
else if (pStart->strInput[x]==' ')
{
z=0;
y++;
printf(".");
}
x++;
i++;
}
}