#include <iostream>
#include <cctype>
#include <cstring>
using namespace std;
bool isPalindrome(const char* input, int size) {
int i = 0, j = size - 1;
while (i < j) {
while (!isalnum(input[i]) && i < j) {
i++;
}
while (!isalnum(input[j]) && i < j) {
j--;
}
if (tolower(input[i]) != tolower(input[j])) {
return false;
}
i++;
j--;
}
return true;
}
int main() {
string str;
cout << "Enter a string: ";
getline(cin, str);
int size = str.length();
const char* input = str.c_str();
bool result = isPalindrome(input, size);
if (result) {
cout << "\nYes, '" << str << "' is a palindrome" << endl;
} else {
cout << "\nNo, '" << str << "' is not a palindrome." << endl;
}
return 0;
}```
this will run on like online c++ compilers but won't run on visual studio 2022
#visual studio 2022 bug or im stupid
33 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
Does it at least compile?
it compiles on but https://www.onlinegdb.com/ but it wont on vs studio 2022
GDB online Debugger
Online GDB is online compiler and debugger for C/C++. You can compile, run and debug code with gdb online. Using gcc/g++ as compiler and gdb as debugger. Currently C and C++ languages are supported.
What is the error message?
What is the error message?
std::string is in the header <string>.
iirc iostream including string is standard
No it's not.
!cppref getline
template<
class CharT,
class Traits,
class Allocator>
std::basic_istream<CharT, Traits>& getline(
std::basic_istream<CharT, Traits>& input,
std::basic_string<CharT, Traits, Allocator>&
str,
CharT delim);
// ... and 3 more
Defined in
So yeah @azure reef you are just not aware enough.
Try including <string>
getline is part of that library
bro yall r jesus thank you
im aware i got it (just a lil bit)
@azure reef Has your question been resolved? If so, run !solved :)
I recently had a discussion and this is exactly why you shouldn't rely on headers implicitly including each other
<iostream> has 0 requirments to include <string> or all of it
I am aware that you shouldn't rely on it in general, I just remembered someone somewhere saying that it was a standard requirement
And that someone was wrong.
Yes I got that
afaik there are 0 dependencies in the STL
I thought that pretty much every include was stand alone
could be wrong on that though :P
Actually looking into iostream, there are standard dependencies. One moment
std::getline relies on std::basic_istream.
anyhow might be a bit wrong, but I thought all of them where "stand" alone in some sense
(Why does Samsung save screenshots as JPG...)
Saves space?
Doesn't save as much space.
The amount of time I care for the losslessness of png is few and far between