im supposé créer un principal avec argoment comme "int main (int argc, char * argve [])" le premier est le type (peut être "int/long/char ") d'un tableau et seconed est la taille, et je dois allouer le tableau basé sur le type choisi j'ai obtenu la taille avec la fonction atoi easlly mais je ne peux pas comprendre comment obtenir le type dans le bon pointeur de choisi tapez je ne comprends pas simplement comment ce casting fonctionne et comment le lancer pour chaque type correctement,
une explication de la façon de le faire correctement?problèmes avec l'allocation d'un tableau avec le type argoment principal
thats ce que je suis arrivé à ce jour
int main(int argc, char* argv[])
{
int size = atoi(argv[2]);
if (strcmp(argv[1], "int") == 0)
{
int* arr = nullptr;
}
if (strcmp(argv[1], "long") == 0)
{
long* arr = nullptr;
}
if (strcmp(argv[1], "char") == 0)
{
char* arr = nullptr;
}
}
Vous avez pas coulé! Êtes-vous censé définir 'void * arr'? C'est une très mauvaise tâche. YAIT (encore un teachert incompétent) –