|
|
|
|
|
|
| Author |
Message |
priyanka *nix forums beginner
Joined: 01 Jun 2006
Posts: 10
|
Posted: Tue Jul 18, 2006 6:13 pm Post subject:
string comparision
|
|
|
Hi there,
I am trying to compare two strings. But I am not able to do so. I use
:
if(function_name[function_number] == function_label[k]){
but this does not work.
I have written down my code:
const char *function_name[(code_addr_t)code_size];
string function_label[(code_addr_t)code_size];
int function_number = 0;
int i = 0;
ifstream inputStream("no_args.txt");
if(!inputStream)
die();
while(!inputStream.eof())
{
getline(inputStream,funcName);
i++;
function_label[i] = funcName;
}
int tot_func = i;
function_number = function_number + 1;
function_name[function_number] = "sumarray";
for(int k = 1; k <=tot_func;k++){
if(function_name[function_number] == function_label[k]){
printf("inside if\n");
}
The execution never enters inside the if { printf("insde if\n");
Thank you in advance,
priya |
|
| Back to top |
|
 |
Ben Pfaff *nix forums Guru
Joined: 08 Apr 2005
Posts: 661
|
Posted: Tue Jul 18, 2006 6:15 pm Post subject:
Re: string comparision
|
|
|
"priyanka" <priyankabhar@gmail.com> writes:
| Quote: | ifstream inputStream("no_args.txt");
if(!inputStream)
die();
|
This is C++ code. Please do not ask C++ questions in
comp.lang.c. comp.lang.c++ may be suitable.
--
int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.\
\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;} |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Thu Jan 08, 2009 6:43 am | All times are GMT
|
|
Debt Consolidation | Babb Fest | Debt Consolidation | Bad Credit Mortgages | PS2 Cheat Codes
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|