Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- void proverka(char *niza){
- int n;
- n=strlen(niza);
- int indeksmajmunce=0;
- for(int i=0;i<n;i++){
- if(*(niza+i)=='@'){
- indeksmajmunce=i;
- break;
- }
- }
- if(indeksmajmunce == 0){
- printf("nee e valinda email adresata");
- return;
- }
- for(int i=0;i<indeksmajmunce;i++){
- if(isalnum(*(niza + i))) {
- /// prodolzi
- }
- else {
- printf("nee e valinda email adresata");
- return;
- }
- }
- int indeks_tocka = 0;
- for(int i=indeksmajmunce + 1;i<n;i++){
- if(*(niza+i)=='.'){
- if((i - indeksmajmunce + 1) <= 0) {
- printf("nee e valinda email adresata");
- return;
- }
- indeks_tocka = i;
- break;
- }
- if(isalpha(*(niza + i))) {
- /// prodolzi
- }
- else {
- printf("Ne e validna email adresata");
- return ;
- }
- }
- /// marija@finki.com
- if(niza[indeks_tocka + 1] == 'c' && niza[indeks_tocka + 2] == 'o' && niza[indeks_tocka + 3] == 'm') {
- printf("VALIDNA EMAIL ADRESA\n");
- return;
- }
- if(niza[indeks_tocka + 1] == 'o' && niza[indeks_tocka + 2] == 'r' && niza[indeks_tocka + 3] == 'g') {
- printf("VALIDNA EMAIL ADRESA");
- return;
- }
- printf("Ne e validna email adresata");
- }
- int main(){
- char A[100];
- scanf("%s", A);
- proverka(A);
- }
- // abc@!asdb
- // asda
- // rezultat = indek_za_pristap: abcasdbasda
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement