Jump to content
Sign in to follow this  
MrTea

Restrictie caractere minuscule!

Recommended Posts

Salut, vreau sa fac un sistem bancomat in C. Vreai ca IBAN-ul sa fie limitat la caractere MAjuscule! Cum fac asta? Am incercat mai jos sa le limitez dar dupa ce citesc sirul de la tastatura nu se intampla nimic! Variabila iban o am asa  char iban[10];

switch(optiune){
		case 1 : {
			printf("\nAveti pe card suma de: %d $ \n", sold);
			break;
		}
		case 2 : {
			printf("\nIntroduceti suma pe care doriti sa o exstageti: \n");
			scanf("%d", &cashout);
			printf("\nAti scos de pe card suma de: %d $", cashout);
			break;
		}
		case 3 : {
			printf("\nIntorudceti IBAN-UL pe care doriti sa faceti transferul\n");
			scanf("%s", &iban);
			if(iban>="a" && iban<="z")	printf("Va rugam introduceti Caractere Majuscule");
			if(iban>="Z" && iban<="Z")	printf ("Ati tastat iban-ul: %s \n", iban);
			break;
		case 4 : {
			printf("\nAti revenit in meniul principal\n");
			break;
		}
		default: printf("Optiune nevalida!");	

 

  • Confused 1

Share this post


Link to post
Share on other sites

3 hours ago, MrTea said:

if(iban>="a" && iban<="z") printf("Va rugam introduceti Caractere Majuscule");

if(iban>="Z" && iban<="Z") printf ("Ati tastat iban-ul: %s \n", iban);

Poti explica ce compari aici?

Share this post


Link to post
Share on other sites
10 hours ago, Stefan said:

Poti explica ce compari aici?

Pai am gasit pe net facuta aceasta  comparatir in c++. Incerc sa compar sirul introdus

Share this post


Link to post
Share on other sites

Pur si simplu, orice ar introduce utilizatorul transformal in majuscule, ex: 

#include <iostream>
#include <cctype>
#include <stdlib.h>

using namespace std;

int main()
{
	char iban[34], i = 0;
	cin >> iban;
	while (iban[i]) {
		if (isalpha(iban[i])) {
			iban[i] = toupper(iban[i]);
		}
		cout << iban[i];
		i++;
	}
}

N-am mai lucrat de ceva vreme in C/C++ si codu' l-am testat intr-un compiler online ca Visual Studio facea figuri si altceva nu avem la indemana, rezultatul a ceea ce am pus eu mai sus e urmatorul:

Input: fsdfsd32DS
Output: FSDFSD32DS

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×