Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- #include <string.h>
- #include <locale.h>
- char options();
- void readRG();
- void findRG(int d);
- char listRG[20][10];
- int nextRG;
- int main(){
- char opt='3';
- int num;
- setlocale(LC_ALL, "Portuguese");
- nextRG = 0;
- while (opt!='5'){
- opt = options();
- switch (opt){
- case '1':
- readRG();
- break;
- case '2':
- printf("O RG começa com qual número? \n");
- num = (getchar()- '0');
- findRG(num);
- break;
- case '0':
- printf("Finalizando \n");
- break;
- default:
- printf("Digite uma opção válida \n");
- break;
- }
- printf("\n");
- }
- system("pause");
- return 0;
- }
- char options(){
- int opt;
- printf("Escolha uma opção: \n");
- printf("1 - Digitar um RG \n");
- printf("2 - Encontrar um RG \n");
- printf("0 - SAIR \n");
- opt = getche();
- printf("\n");
- return opt;
- }
- void readRG(){
- char rg[10];
- int i;
- printf("Digite um RG: \t");
- fflush(stdin);
- gets(rg);
- for(i=0;i<10;i++)
- listRG[nextRG][i]=rg[i];
- if(nextRG<20)
- nextRG = nextRG + 1;
- else
- nextRG = 0;
- }
- void findRG(int d){
- int i;
- char numStr = d+'0';
- for (i=0;i <20;i++){
- if (arr[i][0] == numStr) {
- printf("%s \n", arr[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement