Skip to content

Instantly share code, notes, and snippets.

@kaldas
Created August 30, 2010 05:27
Show Gist options
  • Save kaldas/557053 to your computer and use it in GitHub Desktop.
Save kaldas/557053 to your computer and use it in GitHub Desktop.
/* $ ex1_vetor_ufrj.c ~rcaldasmd~ 30.08.2010
*
* Escreva um programa que leia uma linha de até 80 caracteres
* do teclado e imprima quantos caracteres foram lidos. */
#include <stdio.h>
//string size
#define stsize 80
int i=0; //contador
char string[stsize];
int main()
{
printf("\nCaro senhor, entre com uma string de ate 80 chars:\n");
scanf("%s",string);
while(string[i] != '\0')
{
i++;
}
printf("\nSua string tem: %i char(s)\nbye...\n",i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment