how do you compare strings using only one header file i.e. #include<cstdio>
Im a noob so i might get stuff wrong sorry.
Why doesnt this work:
Code:int i= 0; int check=5; while(a[i]==b[i]){ i++; } if(i==check){ printf("yess"); }else{ printf("nooo")
This is a discussion on How to compare strings in c++ within the C++ Programming forums, part of the General Programming Boards category; how do you compare strings using only one header file i.e. #include<cstdio> Im a noob so i might get stuff ...
how do you compare strings using only one header file i.e. #include<cstdio>
Im a noob so i might get stuff wrong sorry.
Why doesnt this work:
Code:int i= 0; int check=5; while(a[i]==b[i]){ i++; } if(i==check){ printf("yess"); }else{ printf("nooo")
i think
Code:int i = 0; while (a[i] && b[i] && b[i] == a[i]) i++; if( a[i] == b[i]) printf("yess"); else printf("nooo")
Considering that <cstdio> is not about std::string objects or null terminated strings, it sounds like you are really asking how to write a function to compare two null terminated strings, without calling any standard library function in its implementation.Originally Posted by Sanscorp1999
You should provide the smallest and simplest compilable program that demonstrates the problem and tell us how does it not work. That said, linhlonet has a made what I believe is a good guess in post #2, but you really should leave us guessing like that.Originally Posted by Sanscorp1999
C + C++ Compiler: MinGW port of GCC
Version Control System: Bazaar
Look up a C++ Reference and learn How To Ask Questions The Smart Way
And why are you using printf?
For information on how to enable C++11 on your compiler, look here.
よく聞くがいい!私は天才だからね! ^_^