Created
December 17, 2018 14:27
-
-
Save ivanelson/4108ba2ad97e04350522112a5c372a94 to your computer and use it in GitHub Desktop.
Vetor em "C" usando for e while
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
char str[10] ; /*reserva espao para 11 caracteres*/ | |
int i; | |
printf("\nDIGITE Um nome qualquer: "); | |
gets(str); | |
i = 0; | |
printf("\nVou exibir usando a estrutura while: "); | |
while (str[i] != '\0') { // Ultimo caractere de uma string eh sempre '/0' | |
printf("\n%c", str[i]); | |
i++; | |
} | |
printf("\nVou exibir usando a estrutura for: "); | |
for (i =0; i<10; i++) { | |
printf("\n%c", str[i]); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment