i have this code which suppose to get a n input from the file and store it in a char array then i have to inverse it.....
rhis code isnt complete but im getting a wiered error
i see the error when the c++ starts linking not in the compilation procces.
my code is
[CODE=cpp]
#include<iostre am>
#include<cstrin g>
#include<fstrea m>
int reverse(char* str);
using namespace std;
int main()
{
ifstream infile;
ofstream outfile;
infile.open("in put.txt");
outfile.open("o utput.txt");
char name[60];
char invname[60];
if(infile.fail( ))
cout<<"FAILED";
else
{
while(!infile.e of())
{
infile.getline( name,'\n');
reverse(name);
}
}
return 0;
}
int Reverse(char* str)
{
if (NULL==str)retu rn -1; //no string
int l=strlen(str)-1; //get the string length
if (1==l)return 1;
for(int x=0;x < l;x++,l--)
{
str[x]^=str[l]; //triple XOR Trick
str[l]^=str[x]; //for not using a temp
str[x]^=str[l];
}
return 0;
}
[/CODE]
the error is
[CODE=txt]
Linking...
asdqwe.obj : error LNK2001: unresolved external symbol "int __cdecl reverse(char *)" (?reverse@@YAHP AD@Z)
Debug/asdqwe.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
asdqwe.exe - 2 error(s), 0 warning(s)
[/CODE]
can enyone explain the error for me please and tell what to do......ASAP please!!!!!!
rhis code isnt complete but im getting a wiered error
i see the error when the c++ starts linking not in the compilation procces.
my code is
[CODE=cpp]
#include<iostre am>
#include<cstrin g>
#include<fstrea m>
int reverse(char* str);
using namespace std;
int main()
{
ifstream infile;
ofstream outfile;
infile.open("in put.txt");
outfile.open("o utput.txt");
char name[60];
char invname[60];
if(infile.fail( ))
cout<<"FAILED";
else
{
while(!infile.e of())
{
infile.getline( name,'\n');
reverse(name);
}
}
return 0;
}
int Reverse(char* str)
{
if (NULL==str)retu rn -1; //no string
int l=strlen(str)-1; //get the string length
if (1==l)return 1;
for(int x=0;x < l;x++,l--)
{
str[x]^=str[l]; //triple XOR Trick
str[l]^=str[x]; //for not using a temp
str[x]^=str[l];
}
return 0;
}
[/CODE]
the error is
[CODE=txt]
Linking...
asdqwe.obj : error LNK2001: unresolved external symbol "int __cdecl reverse(char *)" (?reverse@@YAHP AD@Z)
Debug/asdqwe.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
asdqwe.exe - 2 error(s), 0 warning(s)
[/CODE]
can enyone explain the error for me please and tell what to do......ASAP please!!!!!!
Comment