Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › C++/C Programming › PLEASE HELP STUPID ISSUE HERE

QuestionPLEASE HELP STUPID ISSUE HERE

Posts 1–12 of 12 · Page 1 of 1
ozza
ozza
PLEASE HELP STUPID ISSUE HERE
hey im having an annoyin dev c++ issue. here is my extremely basic code, dw bout context:


Code:
#include <iostream>
#include <cmath>
#include <windows.h>
char a[100];
int main(){
using namespace std;
cin >> a;
if (a == 'si')
{
cout << a <<" is 'Yes'"<<endl;
}
else if (a == 'hh'){
cout <<"baf"<<endl;
}
else if (a == 'hfs'){
cout <<"fgy"<<endl;
}
else
{
cout <<"fua"<<endl;
}

system ("pause");
return 0;
}
im trying to get it to output the char but it wont run.
when my code was like this:

Code:
char a;
without the value for the char, it ran but only printed out the first letter, because its a char. but when i put it like this:

Code:
char a[100];
i get the error:
ISO C++ forbids comparison between pointer and integer
please help.
#1 · 17y ago
ZE
zeco
Hey, i found your problem.
At all the if( a == 'stuff') you are using 'stuff', when you should be suing "stuff" since single quotations are only for single characters. While double quotations are for strings.
#2 · 17y ago
ozza
ozza
ok i did that and it runs but then if statement dont work. wen i type in si it should type:
Code:
{
cout <<"The English translation for "<< a <<" is 'Yes'"<<endl;
}
but instead it does this statement:
Code:
else
{
cout <<"fua"<<endl;
}
whiich is the else statement so idk wat 2 do now
#3 · 17y ago
ZE
zeco
Quote Originally Posted by ozza View Post
ok i did that and it runs but then if statement dont work. wen i type in si it should type:
Code:
{
cout <<"The English translation for "<< a <<" is 'Yes'"<<endl;
}
but instead it does this statement:
Code:
else
{
cout <<"fua"<<endl;
}
whiich is the else statement so idk wat 2 do now
Yeah, i realize that. Well i'm still learning but i think it has something to do with using character arrays, and the if statement.
#4 · 17y ago
ozza
ozza
how 2 fix?
#5 · 17y ago
P1
P1MP
sherif, just try using a string. Its easier for this purpose and will cause you less trouble
#6 · 17y ago
ozza
ozza
strings never work 4 me wen i try to use cin >>
its only eva worked once and even copying the working source code does nothing
#7 · 17y ago
zhaoyun333
zhaoyun333
You cant compare string using the '==' operator, you need to use strcmp which returns a value of 0 when called and include the string header file.

First off, lets get this character thing straight.

Code:
char a;
This is a character, it holds a single character, it cannot hold a string, nor compare with a string.

Code:
 char a[100]
This is a character array, it holds a pointer to an array of characters.

Code:
char a='a';
You must use the ' ' for a character, otherwise it will not work.
Code:
char a[10]="asdaasdsa";
You must use the " " for a string

Code:
#include <string>
#include <iostream>
#include <cmath>
#include <windows.h>
char a[100];
int main(){
using namespace std;
cin >> a;
if (strcmp(a,"si")==0)
{
cout << a <<" is 'Yes'"<<endl;
}
else if (strcmp(a,"hh")==0){
cout <<"baf"<<endl;
}
else if (strcmp(a,"hfs")==0'){
cout <<"fgy"<<endl;
}
else
{
cout <<"fua"<<endl;
}

system ("pause");
return 0;
}
#8 · 17y ago
why06
why06
Definitive Solution
I compiled this code and it worked as intended... though Im not sure what that intention was. Anyway Read below and you should have your answer.

Quote Originally Posted by ozza View Post
Code:
#include <iostream>
#include <cmath>
#include <windows.h>
using namespace std;

char a[100];

int main()
{
   cin >> a;
   if (a[1] == 'si')
   {
       cout << a <<" is 'Yes'"<<endl;
   }
   //any integer can go in between the brackets [] try using an integer var
   else if (a[1] == 'hh')
   {
       cout <<"baf"<<endl;
   }
   else if (a[1] == 'hfs')
   {
      cout <<"fgy"<<endl;
   }
   else
   {
      cout <<"fua"<<endl;
   }

system ("pause");
return 0;
}
Ok the code was so messed up it took me a while to finde the problem. When u make an array such as char a[100] it is important to understand the the variable a is not a char but an array type. In order to select a single element of an array and compare it you must do so like this if(a[1] == a)



This is how your code should look:
Code:
#include <iostream>
#include <cmath>
#include <windows.h>
using namespace std;

char a[100];

int main()
{
   cin >> a;
   if (a[1] == 'si')
   {
       cout << a <<" is 'Yes'"<<endl;
   }
   //any integer can go in between the brackets [] try using an integer var
   else if (a[1] == 'hh')
   {
       cout <<"baf"<<endl;
   }
   else if (a[1] == 'hfs')
   {
      cout <<"fgy"<<endl;
   }
   else
   {
      cout <<"fua"<<endl;
   }

system ("pause");
return 0;
}
BTW: Proper indentation helps to make your code more readable and frankly easier to understand
I recommend you start posting your code in a more readable format so that we can help you easier
#9 · edited 17y ago · 17y ago
zhaoyun333
zhaoyun333
That is incorrect, when you compare a[1] and 'si' it is wrong. First off, a[i] is actually a character not a string, 'si' is not a character. Using ' ' is only for characters, " " for strings. Therefore when you compare a[1] and 'si' you are comparing the second element in the string with the character 's' since 'si' can only hold one character.
#10 · 17y ago
why06
why06
Quote Originally Posted by zhaoyun333 View Post
That is incorrect, when you compare a[1] and 'si' it is wrong. First off, a[i] is actually a character not a string, 'si' is not a character. Using ' ' is only for characters, " " for strings. Therefore when you compare a[1] and 'si' you are comparing the second element in the string with the character 's' since 'si' can only hold one character.
Well yeh ofcourse, 'si' and 'hh' and 'hfs' are not characters therefore the boolean output for all these expressions would be false , but the point was to get it to compile and run, which it did.

If you ask me personally I think its a little foolhardy to try to use characters arrays with out an accurate understanding of character. And honestly the array had no use in this code... its almost complete gobildy goop :L
#11 · 17y ago
ozza
ozza
just tested and it works thanks tonnes
#12 · 17y ago
Posts 1–12 of 12 · Page 1 of 1

Post a Reply

Similar Threads

  • [HELP] Please Help WIth IssueBy allstar185pl in Combat Arms Hacks & Cheats
    5Last post 17y ago
  • im new here. please help!By maplepawner in Combat Arms Hacks & Cheats
    1Last post 16y ago
  • BIG NOOB here please help learn codingBy brysonlee in C++/C Programming
    25Last post 16y ago
  • Please Help me here!By slimball2001 in General Hacking
    3Last post 18y ago
  • Help me out here, please...!By OutZida in Art & Graphic Design
    1Last post 20y ago

Tags for this Thread

#issue#stupid