years ago i was a programmer in a C++ derivated language that was called Pawn, now i want to try to start in C++, write some things to unrust myself from this beatiful thing that is programming
No, i have never coded with C++ before and with any other language that was not Pawn.
This is the first time i use stackoverflow, sorry if i'm asking a stupid question.
So, this is my code:
I tried to do what the code says like its done in Pawn, almost, and well, i have errors.
#include <stdio.h>
#include <iostream> // I don't know if this is needed
#include <string> // The same for this
using namespace std; // I don't know what this means
int main()
{
int number;
printf("Write the number of croisssants you eat a day\n");
scanf("%d", &number);
printf("The number of croissants that you eat a day is %d", number);
char finalMessage[64]; // This is the way it was made in Pawn, you declare a string and put a max for text
switch(number)
{
// So here i try to use a switch to do this, like i was used to, yes i know how to use if but i'm trying to see if it's this metod is the same thing as it is in Pawn.
case 0: finalMessage = "Oh, so you don't like croissants";
case 1: finalMessage = "Thats okay";
case 2: finalMessage = "Well, if one, why not two?";
default: finalMessage = "Mmmm, i think they are too much.";
}
printf("%s", finalMessage);
return 0;
}
The errors are all this:
error: incompatible types in assignment of 'const char [11]' to 'char [64]' 20 | case 1: finalMessage = "Thats okay";
You can imagine the other ones being the same.
I tried reading a lot of "How to declare a string in C++ but because 2 things...
- I don't understand advanced programming terms (i.e. initialization, constant, cout, etc), i'm working in that
- English is not my first language (It's Spanish), yes, maybe i should use the Spanish forum but i'm trying to get used to the English one because i'm supposed to work with this one in the future
... i can't resolve this.