niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Programming » C
string comparision
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
Author Message
priyanka
*nix forums beginner


Joined: 01 Jun 2006
Posts: 10

PostPosted: Tue Jul 18, 2006 6:13 pm    Post subject: string comparision Reply with quote

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

PostPosted: Tue Jul 18, 2006 6:15 pm    Post subject: Re: string comparision Reply with quote

"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
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
The time now is Thu Jan 08, 2009 6:43 am | All times are GMT
navigation Forum index » Programming » C
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts FAQ 4.32 How do I strip blank space from the beginning/en... PerlFAQ Server Perl 0 Fri Jul 21, 2006 1:03 pm
No new posts FAQ 4.34 How do I extract selected columns from a string? PerlFAQ Server Perl 0 Fri Jul 21, 2006 7:03 am
No new posts print all permutations of string anurag C 10 Thu Jul 20, 2006 5:57 pm
No new posts converting array values to monomaniac21 PHP 11 Thu Jul 20, 2006 10:17 am
No new posts Depricated String Functions in Python Anoop python 14 Thu Jul 20, 2006 6:26 am

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
[ Time: 0.1947s ][ Queries: 16 (0.0937s) ][ GZIP on - Debug on ]