Solved

Error in using strcasestr() in MS Visual C++

Posted on 2016-10-25
2
29 Views
Last Modified: 2016-11-28
Hello,

I used strcasestr() for searching substring in a string but it gives an error even when i used non-standard function using
#define _GNU_SOURCE at the first line of my file. Can you please help?
0
Comment
Question by:Himani Pathak
2 Comments
 
LVL 33

Accepted Solution

by:
sarabande earned 500 total points
ID: 41858877
please post your code (choose CODE from comment box title and then past the code of the function that failed) and error message.

if you get a compiler error it is because strcasestr is not a standard (posix) string function.

if you get a linker error (undefined symbol), it is because the C runtime libraries coming with VC++ do not contain the strcasestr,

you better use stricmp (or _stricmp) for VC++ Compiler.

char * sz1 = "ABC";
char * sz2 = "abC";

int result = stricmp(sz1, sz2);
if (result == 0)  // equal
{

Open in new window

   

or, maybe better, use MFC CString class and function CString::CompareNoCase or CString::Collate (the latter uses the current locale).

char * sz1 = "ABC";
char * sz2 = "abC";

int result = CString(sz1).Collate(sz2);
if (result == 0)  // equal
{

Open in new window

 


Sara
0
 
LVL 14

Expert Comment

by:frankhelk
ID: 41903905
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Accept: sarabande (https:#a41858877)

If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

frankhelk
Experts-Exchange Cleanup Volunteer
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
java inner class, for the sole use of parameter passing 21 77
Dynamically allocate memory 9 58
computer science syllabus 3 81
Copy output image from TWindowsMediaPlayer 6 40
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question