string comparision

P

priyanka

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 = 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
 
B

Ben Pfaff

priyanka said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,143
Latest member
SterlingLa
Top