<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6025800313793339807</id><updated>2011-04-21T14:41:31.474-07:00</updated><title type='text'>Introdução ao C++</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://programacaoinfocultura.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6025800313793339807/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://programacaoinfocultura.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>luciano.infocultura</name><uri>http://www.blogger.com/profile/05721479821982765918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_I14kUyHOnSQ/ShOZHDJXElI/AAAAAAAAAAM/i_rDBvMRiTE/S220/luciano.bmp'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6025800313793339807.post-1292913477248741956</id><published>2009-05-19T22:24:00.000-07:00</published><updated>2009-05-19T22:44:31.808-07:00</updated><title type='text'>printf - cores e cursor</title><content type='html'>&lt;div align="justify"&gt;Precisava eu, mover o cursor pela tela, algo muito fácil com as bibliotecas ncurses ou conio mas depois de dias (muito tempo mesmo) tentando instalas no no netbeans e do codes não obtive exito.&lt;br /&gt;Mas eu continuava precisando mover o cursor pela tela.&lt;br /&gt;Achei em um artigo no viva o linux onde um programador dizia ser possível fazer o movimento apartir do proprio printf () e postava o código.&lt;br /&gt;Infelizmente tambem não funcionou, mas continuei pesquisando e consegui uma maneira de usar o printf() para mover o cursor e tambem mudar a cor do cursor da tela sem adicionar nenhuma bibliotecas especial (a princípio).&lt;br /&gt;&lt;br /&gt;Os códigos abaixo foram testado no netbeans 6.1 e também no code:blocks 8.02 ambos copilador cygwin versao desconhecida rodando apartir do MS Windows XP sp2 pc tipo x86&lt;br /&gt;&lt;br /&gt;void move(int x, int y) {&lt;br /&gt;printf("\033[%d;%df",y,x);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Assim tenho uma funcao que move o cursor para a x,y passadas pela funcao. Se eu fizessem sem funcao poderia passar diretamente pos exemplo para posicao (22,11)&lt;br /&gt;&lt;br /&gt;printf("\033[11;22f");&lt;br /&gt;&lt;/div&gt;&lt;div align="justify"&gt;Embora feio mas funcional.&lt;br /&gt;Para cores temos&lt;br /&gt;&lt;br /&gt;printf("\033[1;%dm",valor);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;No qual as cores estao entre valores de 30 e 50. Sugiro usar um for de 1 ate 50 para testar e cuidado para valores que não alteram as cores pois podem estar alterando algo não perceptível.&lt;br /&gt;&lt;br /&gt;Era isto.&lt;br /&gt;Fonte: &lt;a href="http://www.magnux.org/doc/howto/en/Bash-Prompt-HOWTO-6.php" target="_blank" rel="nofollow"&gt;&lt;span style="font-size:85%;"&gt;http://www.magnux.org/doc/howto/en/Bash-Prompt-HOWTO-6.php&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6025800313793339807-1292913477248741956?l=programacaoinfocultura.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programacaoinfocultura.blogspot.com/feeds/1292913477248741956/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://programacaoinfocultura.blogspot.com/2009/05/printf-cores-e-cursor.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6025800313793339807/posts/default/1292913477248741956'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6025800313793339807/posts/default/1292913477248741956'/><link rel='alternate' type='text/html' href='http://programacaoinfocultura.blogspot.com/2009/05/printf-cores-e-cursor.html' title='printf - cores e cursor'/><author><name>luciano.infocultura</name><uri>http://www.blogger.com/profile/05721479821982765918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_I14kUyHOnSQ/ShOZHDJXElI/AAAAAAAAAAM/i_rDBvMRiTE/S220/luciano.bmp'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6025800313793339807.post-6210304366676365807</id><published>2009-05-14T14:28:00.000-07:00</published><updated>2009-05-19T22:52:01.778-07:00</updated><title type='text'>Iniciando no C++</title><content type='html'>&lt;span style="COLOR: rgb(255,255,255)"&gt;Embora muitos costumem recopilar o kernel como quem faz um cafezinho, muitos ficam complemente perdidos ao iniciar em um linguagem de programação. Até mesmo professores de disciplinas de programação ficam perdidos ao ensinar programação.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,255,255)"&gt;Antes de mais nada temos que esclarecer o seguinte:&lt;/span&gt;&lt;br /&gt;&lt;span style="FONT-WEIGHT: bold; COLOR: rgb(255,255,255)"&gt;Linguagem de programação de alto nível&lt;/span&gt;&lt;span style="COLOR: rgb(255,255,255)"&gt; é o que se chama na Ciência da Computação de linguagens de programação com um nível de abstração relativamente elevado, longe do código de máquina e mais próximo à linguagem humana.&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,255,255)"&gt;O &lt;/span&gt;&lt;span style="FONT-WEIGHT: bold; COLOR: rgb(255,255,255)"&gt;C++&lt;/span&gt;&lt;span style="COLOR: rgb(255,255,255)"&gt; é uma linguagem de programação de alto nível com facilidades para o uso em baixo nível, multiparadigma e de uso geral.&lt;/span&gt;&lt;span style="COLOR: rgb(255,255,255);font-size:78%;" &gt; (fonte wikipédia)&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,255,255)"&gt;Para programar em C++, o programador precisa de uma &lt;/span&gt;&lt;span style="FONT-WEIGHT: bold; COLOR: rgb(255,255,255)"&gt;IDE&lt;/span&gt;&lt;span style="COLOR: rgb(255,255,255)"&gt; (do inglês Integrated Development Environment ou Ambiente Integrado de Desenvolvimento) e um &lt;/span&gt;&lt;span style="FONT-WEIGHT: bold; COLOR: rgb(255,255,255)"&gt;Copilador&lt;/span&gt;&lt;span style="COLOR: rgb(255,255,255)"&gt; que transforma em código executavel o programa que você escreve.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,255,255)"&gt;Muitos professores usam o velho Borland(C) Turbo C++ que fazia de tudo. Dava para escrever nele e executa-lo, tudo isto em ambiente DOS (tela preta). Mas que hoje é quase incompatível com os sistemas operacionais.&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,255,255)"&gt;Outros professores se aventuram "loucamente" em IDEs como Eclipse, Kdeveloper, Code:blocks, NetBenas, etc. que são usadas por programadores profissionais.&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,255,255)"&gt;Vou então propor escrever os programas mais simples do tipo "hello, Word" sem usar IDE. (claro que assim que o aluno se sentir seguro deve-se passar para uma das IDE citadas acima.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,255,255);font-size:130%;" &gt;1 - Abrir um programa de edicao de textos SIMPLES&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,255,255)"&gt;Abra um terminal no linux e crie uma pasta "teste" (mkdir teste) e digite kedit (outras opcao são: kate, joe, nano emacs, vi e muitas outras opcoes)&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,255,255)"&gt;No windows, abra o prompt , crie a pasta (md teste) e digite notepad (bloco de notas) :&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,255,255)"&gt;Digite:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,255,255)"&gt;int main ()&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,255,255)"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,255,255)"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="COLOR: rgb(255,255,255)"&gt;Todo programa em c++ é chamado apartir desta funcao main e que esta entre colchetes é programa em si. Aperte um &lt;/span&gt;&lt;enter style="COLOR: rgb(255,255,255)"&gt;enter para criar uma linha em branco no fim e salve este arquivo como &lt;span style="FONT-WEIGHT: bold"&gt;trabalho1.cpp&lt;/span&gt;. Lembre-se de gravar na sua pasta.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;2 - Compilando o arquivo&lt;/span&gt;&lt;br /&gt;Embora existem vários o mais famoso compilador é o GCC (GNU Compiler Collection) e ele vai ser responsável por fazer seu código virar programa. Digite no terminal:&lt;br /&gt;&lt;br /&gt;gcc -o trabalho1.exe trabalho1.cpp&lt;br /&gt;&lt;br /&gt;Se simplesmente nao aconteceu nada é porque deu tudo certo, mas vamos colocar um erro de uma olhada e tente reparar o erro. Digite novamente kedit e abra seu arquivo, na verdade você nao vai mais fecha-lo, basta digitar kedit &amp;amp; que assim o terminal nao ficara ocupado quando estiver editando. (Usuários M$ dependeram da instalação e configuração do programa &lt;/enter&gt;&lt;span style="COLOR: rgb(255,255,255)"&gt;Cygwin) &lt;/span&gt;&lt;enter style="COLOR: rgb(255,255,255)"&gt;Digite:&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;Ola Mundo!&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Caso nao tenha percebido, o erro é colocar um texto desconhecido do programa, e a linguagem de programação (assim como o computador) aceita apenas comandos; Veja o erro que ocorreu ao executar o gcc.&lt;br /&gt;&lt;br /&gt;[luciano@meupc]$ gcc -o trabalho1.exe trabalho1.cpp&lt;br /&gt;trabalho1.cpp: In function ‘int main()’:&lt;br /&gt;trabalho1.cpp:3: error: ‘Ola’ was not declared in this scope&lt;br /&gt;trabalho1.cpp:3: error: expected `;' before ‘Mundo’&lt;br /&gt;&lt;br /&gt;Ou seja,, deu varios problemas na fucao “int main” mais especificamente na linha 3&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;3 - Usando o comando certo - printf&lt;/span&gt;&lt;br /&gt;Para aparecer uma string (como se chama um texto) na tela do computador devemos usar o comando printf("Ola, mundo"), desta forma o programa fica assim:&lt;br /&gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;printf(“Ola Mundo!”);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Resultado:&lt;br /&gt;&lt;br /&gt;trabalho1.cpp:3: error: stray ‘\342’ in program&lt;br /&gt;trabalho1.cpp:3: error: stray ‘\200’ in program&lt;br /&gt;trabalho1.cpp:3: error: stray ‘\234’ in program&lt;br /&gt;trabalho1.cpp:3: error: stray ‘\342’ in program&lt;br /&gt;trabalho1.cpp:3: error: stray ‘\200’ in program&lt;br /&gt;trabalho1.cpp:3: error: stray ‘\235’ in program&lt;br /&gt;trabalho1.cpp: In function ‘int main()’:&lt;br /&gt;trabalho1.cpp:3: error: ‘Ola’ was not declared in this scope&lt;br /&gt;trabalho1.cpp:3: error: ‘printf’ was not declared in this scope&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;4 - Adicionando Bibliotecas&lt;/span&gt;&lt;br /&gt;Bom, o problema e que nao dissemos de onde vem as funcoes, o copilador continua sem saber de onde vem a palavra “printf“&lt;br /&gt;para resolver este problema devemos colocar o local de onde vem os comandos.fica assim:&lt;br /&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;printf("Ola Mundo!");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;e o Resultado vai ficar assim:&lt;br /&gt;&lt;br /&gt;[&lt;/enter&gt;&lt;span style="COLOR: rgb(255,255,255)"&gt;luciano@meupc&lt;/span&gt;&lt;enter style="COLOR: rgb(255,255,255)"&gt;&lt;stdio.h&gt; teste]$ gcc -o trabalho1.exe trabalho1.cpp&lt;br /&gt;/tmp/ccKfNvbV.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'&lt;br /&gt;collect2: ld returned 1 exit status&lt;br /&gt;&lt;br /&gt;Pelo menos há uma menor quantidade de erros.&lt;br /&gt;&lt;span style="font-size:130%;"&gt;&lt;br /&gt;5 - Usando o copilador certo g++&lt;/span&gt;&lt;br /&gt;Qual o problema,, o problema é q estamos trabalhando com C++ e nao C puro.. E para copilar um programa em c++ devemos usar o g++,,&lt;br /&gt;&lt;br /&gt;[&lt;/STDIO.H&gt;&lt;/enter&gt;&lt;span style="COLOR: rgb(255,255,255)"&gt;luciano@meupc&lt;/span&gt;&lt;enter style="COLOR: rgb(255,255,255)"&gt;&lt;stdio.h&gt; teste]$ g++ -o trabalho1.exe trabalho1.cpp&lt;br /&gt;&lt;br /&gt;E sem erros, mas cade meu “Ola Mundo”? Digite ls (ou dir caso M$)&lt;br /&gt;&lt;br /&gt;[&lt;/STDIO.H&gt;&lt;/enter&gt;&lt;span style="COLOR: rgb(255,255,255)"&gt;luciano@meupc&lt;/span&gt;&lt;enter style="COLOR: rgb(255,255,255)"&gt;&lt;stdio.h&gt;1 teste]$ ls&lt;br /&gt;trabalho1.cpp trabalho1.cpp~ trabalho1.exe&lt;br /&gt;[&lt;/STDIO.H&gt;&lt;/enter&gt;&lt;span style="COLOR: rgb(255,255,255)"&gt;luciano@meupc&lt;/span&gt;&lt;enter style="COLOR: rgb(255,255,255)"&gt;&lt;stdio.h&gt;1 teste]$&lt;br /&gt;&lt;br /&gt;Ha 3 arquivos: o cpp é o criamos, o cpp~ é uma copia de segurança que o kedit cria, e o trabalho1.exe é um executavel linux (repare na cor verde), caso vc esteja no linux digite assim&lt;br /&gt;&lt;br /&gt;[&lt;/STDIO.H&gt;&lt;/enter&gt;&lt;span style="COLOR: rgb(255,255,255)"&gt;luciano@meupc&lt;/span&gt;&lt;enter style="COLOR: rgb(255,255,255)"&gt;&lt;stdio.h&gt; teste]$ ./trabalho1.exe&lt;br /&gt;Ola Mundo![&lt;/STDIO.H&gt;&lt;/enter&gt;&lt;span style="COLOR: rgb(255,255,255)"&gt;luciano@meupc&lt;/span&gt;&lt;enter style="COLOR: rgb(255,255,255)"&gt;&lt;stdio.h&gt; teste]$&lt;br /&gt;&lt;br /&gt;É realmente tanta emoção que o prompt ficou do lado do resolva seu problema adicionando um “\n” do final de seu texto:&lt;br /&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;printf("Ola Mundo!\n");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Nao esqueca de salvar, copilar e depois executar.&lt;br /&gt;Sugestao:: pesquise no google cada palavra estranha q vc leu por aqui..&lt;br /&gt;Teste agora em um repeticao de 10 vezes:&lt;br /&gt;&lt;br /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;int i;&lt;br /&gt;for (i=0; i&lt;10;&gt;&lt;/enter&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6025800313793339807-6210304366676365807?l=programacaoinfocultura.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://programacaoinfocultura.blogspot.com/feeds/6210304366676365807/comments/default' title='Postar comentários'/><link rel='replies' type='text/html' href='http://programacaoinfocultura.blogspot.com/2009/05/inciando-no-c.html#comment-form' title='0 Comentários'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6025800313793339807/posts/default/6210304366676365807'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6025800313793339807/posts/default/6210304366676365807'/><link rel='alternate' type='text/html' href='http://programacaoinfocultura.blogspot.com/2009/05/inciando-no-c.html' title='Iniciando no C++'/><author><name>luciano.infocultura</name><uri>http://www.blogger.com/profile/05721479821982765918</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='20' height='32' src='http://1.bp.blogspot.com/_I14kUyHOnSQ/ShOZHDJXElI/AAAAAAAAAAM/i_rDBvMRiTE/S220/luciano.bmp'/></author><thr:total>0</thr:total></entry></feed>
