C Board  

Go Back   C Board > General Programming Boards > C Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 03-23-2009, 04:44 AM   #1
Registered User
 
Join Date: Jun 2008
Posts: 5
Exclamation language translator (having problems in tokenizing)

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++;
	}
}
jumbo2410 is offline   Reply With Quote
Old 03-23-2009, 05:16 AM   #2
CSharpener
 
vart's Avatar
 
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   Reply With Quote
Old 03-23-2009, 05:29 AM   #3
Registered User
 
Join Date: Jun 2008
Posts: 5
piffff.... stupid me... so should that work now?
XD
jumbo2410 is offline   Reply With Quote
Reply

Tags
c program, pointers, tokenize, translator

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 06:06 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22