Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Fixing Linker Errror in C

$
0
0
Hello everyone. I have a problem with my c program. There's no error in compiling the program but when I run it, I got stuck with this error:

linker error: Undefined symbol Gen_token(char near*, char[10]near*) in module E:OPTIMIZED.CPP

Can someone help me to fix it? thanks a lot!

/*******************************************************************
Program for Code Optimization Technique of Constant Folding
*******************************************************************/
#include<stdio.h>
#include<string.h>
#include<conio.h>
#include<stdlib.h>
#include<ctype.h>
struct ConstFold
{
char new_Str[10];
char str[10];
}Opt_Data[20];

void ReadInput(char Buffer[],FILE *Out_file);
int Gen_token(char str[],char Tokens[][10]);
int New_Index=0;
int main()
{
FILE *In_file,*Out_file;
char Buffer[100],ch;
int i=0;
In_file = fopen("d:\\code.txt","r");
Out_file = fopen("d:\\output.txt","w");
clrscr();
while(1)
{
ch = fgetc(In_file);
i=0;
while(1)
{
if(ch == '\n')
break;
Buffer[i++]=ch;
ch = fgetc(In_file);
if(ch == EOF)
break;
}//End while
if(ch ==EOF)
break;
Buffer[i]='\0';
ReadInput(Buffer, Out_file);//writing to the output file
}//End while
return 0;
}//End main

void ReadInput(char Buffer[],FILE *Out_file)
{
char temp[100],Token[10][10];
int n,i,j,flag=0;
strcpy(temp,Buffer);
n= Gen_token(temp,Token);
for(i=0;i<n;i++)
{
if(!strcmp(Token[i],"="))
{
if(isdigit(Token[i+1][0])||Token[i+1][0] == '.')
{
/*If yes then saving that number and its variable
In the Opt_Data array*/
flag=1;
strcpy(Opt_Data[New_Index].new_Str,Token[i-1]);
strcpy(Opt_Data[New_Index++].str,Token[i+1]);
}//End if
}//End if
}//End for

if(!flag)
{
for(i=0;i<New_Index;i++)
{
for(j=0;j<n;j++)
{
if(!strcmp(Opt_Data[i].new_Str,Token[j]))
strcpy(Token[j],Opt_Data[i].str);
}//End for
}//End for
}//End if
fflush(Out_file);
strcpy(temp,"");
for(i=0;i<n;i++) /*Loop to obtain complete tokens*/
{
strcat(temp,Token[i]);
if(Token[i+1][0]!=','||Token[i+1][0] != ',')
strcat(temp," ");
}//End for
strcat(temp,"\n\0");
fwrite(&temp,strlen(temp),1,Out_file);
}

/*The Gen_Token function breaks the input line into tokens*/
int Gen_Token(char str[], char Token[][10])
{
int i=0,j=0,k=0;
while(str[k]!='\0')
{
j=0;
while(str[k] ==' '|| str[k] =='\t')
k++;
while(str[k]!=' '&& str[k]!='\0'&& str[k]!= '=' && str[k] != '/'&& str[k]!= '+' && str[k] != '-'&& str[k]!= '*' && str[k] != ',' && str[k]!= ';')
Token[i][j++] = str[k++];
Token[i++][j] = '\0';
if(str[k] == '='|| str[k] == '/'|| str[k] == '+'|| str[k]== '-'|| str[k] == '*'|| str[k] == '*'|| str[k] == ','||str[k] == ';')
{
Token[i][0] = str[k++];
Token[i++][1] = '\0';
}//End if
if (str[k] == '\0')
break;
}//End while
return i;
}


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>