字符串C ++ [英] Strings C++
问题描述
您好。我在C ++中遇到字符串问题。
我正在使用gcc / g ++ gnu / linux编译器。
如何用C ++中的字符串和常量进行测试?
例如:
char string [10];
if(string ==" test"){
printf(" OK");
}
我正在寻求帮助。
谢谢。
Hello. I have a problem with strings in C++.
I''m using gcc/g++ gnu/linux compiler.
How i can do tests with strings and constants in C++?
Eg:
char string[10];
if (string == "test") {
printf("OK");
}
I''m wating for help.
Thanks.
推荐答案
lu **@flypublicidade.com.br 写道:
你好。我在C ++中遇到字符串问题。
我正在使用gcc / g ++ gnu / linux编译器。
如何用C ++中的字符串和常量进行测试?
例如:
char string [10];
if(string ==" test"){
printf(" OK");
}
我正在寻求帮助。
谢谢。
Hello. I have a problem with strings in C++.
I''m using gcc/g++ gnu/linux compiler.
How i can do tests with strings and constants in C++?
Eg:
char string[10];
if (string == "test") {
printf("OK");
}
I''m wating for help.
Thanks.
你要么使用strcmp要么创建一个==运算符。你不能直接将字符串
与字符串进行比较。
希望这会有所帮助。
you either use strcmp or create a == operator. you can''t compare string
to string directly.
hope this will help.
lu**@flypublicidade.com.br 写道:
您好。我在C ++中遇到字符串问题。
我正在使用gcc / g ++ gnu / linux编译器。
如何用C ++中的字符串和常量进行测试?
例如:
char string [10];
if(string ==" test"){
printf(" OK");
}
我正在寻求帮助。
谢谢。
Hello. I have a problem with strings in C++.
I''m using gcc/g++ gnu/linux compiler.
How i can do tests with strings and constants in C++?
Eg:
char string[10];
if (string == "test") {
printf("OK");
}
I''m wating for help.
Thanks.
你要么使用strcmp要么创建一个==运算符。你不能直接将字符串
与字符串进行比较。
希望这会有所帮助。
you either use strcmp or create a == operator. you can''t compare string
to string directly.
hope this will help.
我用过strcmp,但是例如如果我比较爱情和ovel它
将返回true。
这是一个问题,因为它不是真的。
谢谢。
I''ve used strcmp, but for example if i compare "love" and "ovel" it
will return true.
And its is a problem, cause it isn''t true.
Thanks.
lu**@flypublicidade.com.br 写道:
你好。我在C ++中遇到字符串问题。
我正在使用gcc / g ++ gnu / linux编译器。
如何用C ++中的字符串和常量进行测试?
例如:
char string [10];
Hello. I have a problem with strings in C++.
I''m using gcc/g++ gnu/linux compiler.
How i can do tests with strings and constants in C++?
Eg:
char string[10];
这不是C ++字符串。
That isn''t a C++ string.
if(string ==" test") {
printf(" OK");
}
if (string == "test") {
printf("OK");
}
使用C ++字符串。
std :: string无论如何;
if(无论= ='"测试)......
-
Ian Collins。
Use C++ strings.
std::string whatever;
if( whatever == "test ) ...
--
Ian Collins.
这篇关于字符串C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!