CLion not recognizing strcmp() function !

已回答

 

I am not able to use strcmp() function.

It says that it is defined in string.h and I've included it but it is not recognizing.

 

0

Hello!

I see no warnings in CLion 2020.1.1 for the sample code from https://en.cppreference.com/w/cpp/string/byte/strcmp, for example:

Do you see the warnings for this exact code on your side? If no, then the issue is related to your particular code and we will need a short self-contained code sample.

0

I'm not able to see any warnings on the example code but my code shows warning messages!

 

Please Help!

 

Regards,

Rohit

0

This is the code.

#include <iostream>
#include <math.h>
#include <algorithm>
#include <ctype.h>
#include <cstring>
#include <string>
#include <string.h>
#include <array>
#include <stdlib.h>
#include <vector>
#include <stdio.h>
#include <cstdio>
#include <iterator>

using namespace std;

#define st(x) string x;
#define get(x) cin >> x;
#define put(x) cout << x << "\n";
#define rt return 0;

int main()
{
#ifndef ONLINE_JUDGE
freopen("C:/Users/Rohit/CLionProjects/CurrentWS/input.txt", "r", stdin);
freopen("C:/Users/Rohit/CLionProjects/CurrentWS/output.txt", "w", stdout);
#endif

ios_base::sync_with_stdio(false);
cin.tie(NULL);

st(x)
st(y)

get(x)
get(y)

put(strcmp(x,y))

rt
}
0

What compiler do you use? Please attach a screenshot of `File | Settings | Build, Execution, Deployment | Toolchains` (please capture the screenshot after the compiler detection is completed).

I can't compile your code with clang or gcc:

0

 

Hope it is helpful.

Regards,

Rohit

0

The code provided in this comment doesn't compile with MSVC toolchain on my side:

 

And I checked several compilers on https://godbolt.org/ - the code doesn't compile.

 

Are you sure this exact code compiles on your side?

Please send the entire project to clion-support at jetbrains.com. And the idea.log file (Help | Show Log in ...) too. Note that logs might contain private user's information (like file paths and names). 

0

My code compiles perfectly without strcmp().

Where do u want me to send my project?

0

 >My code compiles perfectly without strcmp().

Without? Does it compile with strcmp()?

0

The provided project can't be built with any toolchain - the compilation error appears on the put(strcmp(x,y))line. It means that the code is incorrect and CLion indicated the error correctly.

0

This forum is dedicated to CLion. And this issue is not CLion related.

You can ask questions about c++ programming, for example, on https://stackoverflow.com/.

0

Thank you for your help.

But I think that it is not my error as the function strcmp() is not working on your IDE.

It would be very nice of you if you could resolve this issue.

0

>the function strcmp() is not working on your IDE

The code you wrote doesn't compile anywhere which means it's not a valid C++ code. There is an error in your code and CLion correctly indicates that. In other words, CLion works correctly, there is no issue with CLion. 

Correcting the user's code is out of scope of CLion support.

0

请先登录再写评论。