Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <time.h>
- #include <stdlib.h>
- #include <string.h>
- #include <locale.h>
- typedef struct{
- char VetorFacil[20];
- }VETORES;
- void carregaPalavrasFacil(VETORES *vetorFuncFacil);
- void mostraPalavrasFacil();
- void pontuacao();
- void main(){
- int op, i;
- VETORES vetorFuncFacil[10] = {'a','b','c','d','e','f','g','h','i','j'};
- printf("Escolha o nivel em que deseja jogar: \n");
- puts("1) Facil");
- puts("2) Medio");
- puts("3) Dificil");
- puts("4) Ajuda");
- fflush(stdin);
- scanf("%i", &op);
- switch(op){
- case 1: {
- carregaPalavrasFacil(vetorFuncFacil);
- break;
- }
- case 2: {
- printf("Sim\n");
- break;
- }
- case 3: {
- printf("Sim\n");
- break;
- }
- case 4:{
- puts("Ajuda!");
- break;
- }
- default: {
- puts("Opção Inválida!");
- break;
- }
- }
- }
- void carregaPalavrasFacil(VETORES *vetorFuncFacil){
- int i, cont = 0, pegalinha, para;
- char line[20];
- FILE *arquivo;
- arquivo = fopen("facil.txt", "r");
- if(arquivo == NULL){
- printf("Arquivo Inválido!\n");
- exit(1);
- }else{
- for(cont = 0; cont < 20; cont++){
- int numero = rand() % 20;
- do{
- if(pegalinha == numero){
- fgets(line, sizeof(line), arquivo);
- strcpy((*vetorFuncFacil).VetorFacil, line);
- para = 1;
- }else{
- pegalinha++;
- }
- }while(para != 1);
- }
- }
- for(i=0; i<=10; i++){
- printf("%s\n", vetorFuncFacil[i].VetorFacil);
- }
- fclose(arquivo);
- }
Advertisement
Add Comment
Please, Sign In to add comment