I don't remember how to do this in C++:
#include <iostream>
#include <conio.h>
#include <string.h>
int main(){
char categorias[3][20];
/*char pais[3][20];
char movimiento[3][50];
char obras[100][50]; */
categorias[0]="Alta";
categorias[1]="Media";
categorias[2]="Baja";
}
This throws this error: 19 15 C:\Users\dell\Desktop\Subasta.cpp [Error] incompatible types in assignment of 'const char [5]' to 'char [20]';
Long time ago I don't use C++ and I can´t solve the problem.
Use C++ abstractions and containers from the standard library:
int main()
{
using namespace std::string_literals;
auto categorias = std::vector{"Alta"s, "Media"s, "Baja"s};
// Or if you know you have a fixed number of categories:
auto categorias = std::array{"Alta"s, "Media"s, "Baja"s};
}
To copy the string literal into the char array
strcpy(categorias[0], "Alta");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.