Revision: 23148
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at January 31, 2010 13:49 by sebastianf
Initial Code
#include <stdio.h>#include <string.h> /* Version mit vorgegebenen Text int main (int argc, const int *argv){ int i=0, tab=0, blank=0, nl=1; char text[160]; printf("\nBitte geben Sie einen Text ein\n"); strcpy(text,"was machen wir heute noch?\nich\tweis\tnicht."); while(text[i]){ if(text[i]=='\t') tab++; else if(text[i]==' ') blank++; else if(text[i]=='\n') nl++; i++; } printf("\n'%s'\nhat %i Leerzeichen, %i Tabulatorstellen und %i Zeilen", text, blank, tab, nl); } */ int main (int argc, constchar * argv[]){ int c, tab=0, nl=1, blank=0; while((c=getchar())!=EOF){ if(c==' ') blank++; else if(c=='\t') tab++; else if(c=='\n') nl++; } printf("\nDer Text hat %i Leerzeichen, %i Tabulatorstellen und %i Zeilen", blank, tab, nl); }
Initial URL
Initial Description
Initial Title
count blanks tabs newlines
Initial Tags
Initial Language
C