![]() |
| | #1 |
| Registered User Join Date: Jun 2008
Posts: 5
| 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++;
}
}
|
| jumbo2410 is offline | |
| | #2 |
| CSharpener Join Date: Oct 2006
Posts: 5,242
| void Menu(); void Menu(ptrNode pStart); Don't you see any difference here?
__________________ If I have eight hours for cutting wood, I spend six sharpening my axe. |
| vart is offline | |
| | #3 |
| Registered User Join Date: Jun 2008
Posts: 5
| piffff.... stupid me... so should that work now? XD |
| jumbo2410 is offline | |
![]() |
| Tags |
| c program, pointers, tokenize, translator |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| The value of learning a new programming language | h3ro | General Discussions | 21 | 06-13-2009 01:48 AM |
| ASM to C language | TAZIN | C Programming | 22 | 06-03-2009 06:29 AM |
| No clue how to make a code to solve problems! | ctnzn | C Programming | 8 | 10-16-2008 02:59 AM |
| d programming language - a better c++? | kypronite | Tech Board | 8 | 08-24-2008 12:37 PM |
| Visual J# | mfc2themax | A Brief History of Cprogramming.com | 0 | 10-08-2001 02:41 PM |