Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // title: printf
- // ide: apple xcode
- // author: paulogp
- #include <stdio.h>
- #include <string.h>
- int main (int argc, const char * argv[])
- {
- char *the_name;
- char the_buffer[255];
- char the_buffer2[255];
- int the_num;
- float the_float;
- // output do simbolo "
- printf("ola ou \"hello\"\n");
- printf("\n");
- // output do simbolo %
- printf("analise a 100%%\n");
- printf("\n");
- // utilizacao de vars
- the_name = "oki";
- the_num = 99;
- the_float = 3.1415926535897932384626433832795;
- printf("output string: %s | inteiro: %i | duas casas significativas: %.2f\n", the_name, the_num, the_float);
- printf("\n");
- // indentacao
- the_name = "celulas (media de vida)";
- the_num = 120;
- printf("%35s %15i\n", the_name, the_num);
- printf("\n");
- // formatacao usando constante string
- the_name = "zebra";
- printf("a %s tem %s\n", the_name, "riscas");
- printf("\n");
- // formatacao usando constante operacao inteira
- the_name = "resultado";
- printf("o %s de 7 + 5 e %i\n", the_name, (7 + 5));
- printf("\n");
- // copia constante para a var the_buffer
- memcpy (the_buffer, "texto de exemplo salta para a variavel\n", sizeof(the_buffer));
- printf("%s\n", the_buffer);
- // faz output de parte de string pelo "metodo de copia"
- for (int i = 9; i < sizeof(the_buffer); ++i)
- the_buffer2[i-9] = the_buffer[i];
- printf("%s\n", the_buffer2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement