If you can't read please download the document
Upload
regis-magalhaes
View
8.905
Download
2
Embed Size (px)
Citation preview
String 2. String
3. String
4. String
5. String #include main() { charnome[6]; printf ( "Digite um nome: " ); gets (nome); printf ( "Ola, %s " , nome); system( "pause" ); } 6. String
7. String #include main() { charnome1[21], nome2[21]; printf ( "Digite um nome: " ); gets (nome1); printf ( "Digite um nome: " ); fgets (nome2,21,stdin); printf ( " Nomes: %s - %s" , nome1, nome2); } 8. String #include main(){ charnome[10] ="Joao" ; printf ( "String: %s " , nome); printf ( "Terceira letra: %c " , nome[2]); printf ( "Quarta letra: %c " , nome[3]); nome[2] ='h' ; nome[3] ='n' ; printf ( "Agora a terceira letra eh: %c " , nome[2]); printf ( "Agora a quarta letra eh: %c " , nome[3]); printf ( "String resultante: %s " , nome); system( "pause" ); } 9. String #include main(){ charnome[10]; printf ( "Digite um nome: " ); gets (nome); printf ( " String: %s " , nome); printf ( "Terceira letra: %c " , nome[2]); printf ( "Quarta letra: %c " , nome[3]); printf ( "o tamanho da string eh: %d " , strlen(nome)); printf ( "o ultimo caractere eh: %c " , nome[strlen(nome)-1]); nome[2] ='h' ; nome[3] ='n' ; printf ( "Agora a terceira letra eh: %c " , nome[2]); printf ( "Agora a quarta letra eh: %c " , nome[3]); printf ( "String resultante: %s " , nome); system( "pause" ); } 10. String funes
11. String funes #include #include main() { charnome1[] ="Regis" ; printf ( "%s" ,nome1); charnome2[100]; strcpy(nome2,"Isaac" ); printf ( "%s" ,nome2); strcat(nome2, " Newton" ); printf ( "%s" ,nome2); strcpy(nome2, "Maria" ); printf ( "%s" ,nome2); } 12. Funes no padronizadas