[ create a new paste ] login | about

Link: http://codepad.org/NhEjZNad    [ raw code | fork ]

C, pasted on Jul 23:
#include <stdio.h>
#include <string.h>//Protótipos das funções strlen() e strcmp().

#define MAX  2
int main(void) {
    char string[2][255];
    int size[2], i;
    
    for (i = 0; i < MAX; i++){
        printf("String %d:", i + 1);
        gets(string[i]);//Função gets() para ler espaços.
        size[i] = strlen(string[i]); //Retorna o tamanho da string
    }
    
    for (i = 0; i < MAX; i++){
        printf("\nTamanho da string %d \"%s\": %d caracteres", i + 1, string[i], size[i]);
        if (i > 0){
           if (size[i-1] != size[i])//Compara o tamanho das strings.
                printf("\n\nAs duas strings sao de tamanhos diferentes.");
           if (strcmp(string[0],string[1]) != 0)//Verifica se as strings possuem o mesmo conteúdo.
                printf("\n\nAs duas strings possuem conteudos diferentes.\n\n");
        }
    }

system("PAUSE");
return 0;
}


Create a new paste based on this one


Comments: