Mudanças entre as edições de "Guia Básico de C"
Ir para navegação
Ir para pesquisar
Linha 16: | Linha 16: | ||
| rowspan="4" | <tt>[http://opengroup.org/onlinepubs/007908775/xsh/string.h.html string.h]</tt> || Informação || <tt>strlen</tt> || Informa o tamanho da ''string''. || <syntaxhighlight lang=c>tamanho = strlen(frase);</syntaxhighlight> || [http://mico.ead.cpdee.ufmg.br/cursos/C/aulas/c520.html#c524.html strlen] | | rowspan="4" | <tt>[http://opengroup.org/onlinepubs/007908775/xsh/string.h.html string.h]</tt> || Informação || <tt>strlen</tt> || Informa o tamanho da ''string''. || <syntaxhighlight lang=c>tamanho = strlen(frase);</syntaxhighlight> || [http://mico.ead.cpdee.ufmg.br/cursos/C/aulas/c520.html#c524.html strlen] | ||
|- | |- | ||
− | | Busca || <tt>strchr</tt> e <tt>strchr</tt> || Localizam a primeira e última ocorrência, respectivamente, de um caractere na ''string''. || <syntaxhighlight lang=c>primeiro = strchr(frase, 'a'); | + | | Busca || <tt>strchr</tt> e <tt>strchr</tt> || Localizam a primeira e última ocorrência, respectivamente, de um caractere na ''string''. || <syntaxhighlight lang=c>primeiro = strchr(frase, 'a'); |
+ | ultimo = srtrchr(frase, 'a');</syntaxhighlight || [http://mico.ead.cpdee.ufmg.br/cursos/C/aulas/c520.html#c524.html strlen] | ||
|- | |- | ||
| Comparação || <tt>strcmp</tt> || Compara duas ''strings''. || <syntaxhighlight lang=c>iguais = strcmp(frase, palavra);</syntaxhighlight> || [http://mico.ead.cpdee.ufmg.br/cursos/C/aulas/c520.html#c525.html strcmp] | | Comparação || <tt>strcmp</tt> || Compara duas ''strings''. || <syntaxhighlight lang=c>iguais = strcmp(frase, palavra);</syntaxhighlight> || [http://mico.ead.cpdee.ufmg.br/cursos/C/aulas/c520.html#c525.html strcmp] | ||
|- | |- | ||
| Cópia || <tt>strcpy</tt> || Copia o conteúdo de uma ''string'' para outra. || <syntaxhighlight lang=c>strcpy(destino, origem);</syntaxhighlight> || [http://mico.ead.cpdee.ufmg.br/cursos/C/aulas/c520.html#c522.html strcpy] | | Cópia || <tt>strcpy</tt> || Copia o conteúdo de uma ''string'' para outra. || <syntaxhighlight lang=c>strcpy(destino, origem);</syntaxhighlight> || [http://mico.ead.cpdee.ufmg.br/cursos/C/aulas/c520.html#c522.html strcpy] | ||
− | |||
− | |||
− | |||
− | |||
|} | |} |
Edição das 12h47min de 26 de novembro de 2009
Bilioteca | Funcionalidade | Função | O que faz? | Exemplo | Referência do curso de C |
stdio.h | Entrada de Dados | scanf | Lê informação da entrada de dados padrão. | scanf("%s", frase);
|
scanf |
fscanf | Lê informação de um arquivo. | fscanf(arquivo, frase);
|
fscanf | ||
fgets | Equivalente a fscanf, porém especifica a quantidade de bytes a serem lidos. | fgets(frase, sizeof(frase), arquivo);
|
fgets | ||
Saída de Dados | printf | Imprime uma informação na tela. | printf("O usuário %s tem %d anos\n.", usuario, idade);
|
printf | |
fprintf | Imprime uma informação em um arquivo. | fprintf(arquivo1, "O usuário %s tem %d anos\n.", usuario, idade);
|
fprintf | ||
fputs | Equivalente ao fprintf, adicionando um ENTER ao final da linha. | fputs("O usuário %s tem %d anos\n.", usuario, idade, arquivo1);
|
fputs | ||
string.h | Informação | strlen | Informa o tamanho da string. | tamanho = strlen(frase);
|
strlen |
Busca | strchr e strchr | Localizam a primeira e última ocorrência, respectivamente, de um caractere na string. | primeiro = strchr(frase, 'a');
ultimo = srtrchr(frase, 'a');</syntaxhighlight || [http://mico.ead.cpdee.ufmg.br/cursos/C/aulas/c520.html#c524.html strlen]
|-
| Comparação || <tt>strcmp</tt> || Compara duas ''strings''. || <syntaxhighlight lang=c>iguais = strcmp(frase, palavra);
|
strcmp | |
Cópia | strcpy | Copia o conteúdo de uma string para outra. | strcpy(destino, origem);
|
strcpy |