Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,290 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,070 people online right now. Registration is fast and FREE... Join Now!




how can i compare in c language.?

 
Reply to this topicStart new topic

how can i compare in c language.?, if ( strncmp(sIncidentSummary,"Telecom")

ambi21hs
post 11 Mar, 2008 - 08:55 AM
Post #1


New D.I.C Head

*
Joined: 11 Mar, 2008
Posts: 4

if ( strncmp(sIncidentSummary,"Telecom")==0) but the sIncidentSummary is the variable name ok. Its store problem type full name like /Telecom/Trouble Ticket/NOC/Voice\LD/PBX VNET Trunks/ so hw can I compare only with the telecom like only 7letters.?



how can i copmare in c language.? kindly help me out with this.
my id is ambi21hs@gmail.com kindly send it to my id..plzz
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 11 Mar, 2008 - 09:04 AM
Post #2


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,170



Thanked 33 times

Dream Kudos: 25
My Contributions


Is the part you want to compare it to always going to be in the same place (immediately after the first slash)? If so, you can compare like so:

CODE

if(strncmp (sIncidentSummary,"/xxxxxxx",7) == 0)

although you'd have to potentially add a slash to the beginning of the variable as well.

Might be easier to see if the substring exists in the full string:
CODE

if(strstr(sIncidentSummary,"Telecom")!=NULL)

User is offlineProfile CardPM

Go to the top of the page

ambi21hs
post 11 Mar, 2008 - 11:09 PM
Post #3


New D.I.C Head

*
Joined: 11 Mar, 2008
Posts: 4

QUOTE(Amadeus @ 11 Mar, 2008 - 10:04 AM) *

Is the part you want to compare it to always going to be in the same place (immediately after the first slash)? If so, you can compare like so:

CODE

if(strncmp (sIncidentSummary,"/xxxxxxx",7) == 0)

although you'd have to potentially add a slash to the beginning of the variable as well.

Might be easier to see if the substring exists in the full string:
CODE

if(strstr(sIncidentSummary,"Telecom")!=NULL)




so which one i can use the first one or the secon done.?
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 12 Mar, 2008 - 06:38 AM
Post #4


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,170



Thanked 33 times

Dream Kudos: 25
My Contributions


Depends on your answer to my question.
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/22/08 01:17AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month