Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int number(int num);
- int main()
- {
- system("color F0");
- int num,i;
- printf("Input number if you want to count:\nspace-1 \ntabulations-2 \nlines-3\n");
- scanf("%d",&num);
- if(num<1 || num>3){
- printf("Error,please enter number between 1 and 3\n");
- scanf("%d",&num);
- }
- if(num<=2){
- i=number(num);
- printf("in total %d\n",i);
- }
- if(num=3){
- i=number(num);
- printf("%d\n",i-1 );
- }
- }
- int number(int num)
- {
- int c,amount=0;
- while((c=getchar())!=EOF){
- if(num==1){
- if(c==' '){
- ++amount;
- }
- }
- if(num==2){
- if(c=='\t'){
- ++amount;
- }
- }
- if(num==3){
- if(c=='\n'){
- ++amount;
- }
- }
- }
- return amount;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement