I'm trying to build a program where the user picks a consonant/vowel and a random letter is chosen and added to a string each time, similar to the TV show countdown. I'm hit with the error in the title. When I try to compile the console reads that the file is not readable as an executable.
// April16Assignment.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdlib.h>
#include <string>
using namespace std;
int main(){
char type, letters[10];
char vowels[6] = { 'A', 'E', 'I', 'O', 'U' };
char consonants[22] = { "B", "C", "D", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "V", "W", "X", "Y", "Z" };
int i, j, k, l;
for (i = 0; i < 9; i++){
printf("Vowel or consonant? (V/C)");
scanf("%c", &type);
if (type == 'V')
for (k = 0; k<1; k++){
j = (rand() % 5);
strcat(letters, vowels[j]);
}
if (type == 'C')
for (l = 0; l<1; l++){
j = (rand() % 21);
strcat(letters, consonants[j]);
}
else
printf("Invalid!");
break;
}
printf("%s", letters);
return 0;
}
Aucun commentaire:
Enregistrer un commentaire