Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int number(int num);
- int main()
- {
- int num,spc,n;
- printf("Input number if you want to count:\nspace-1 \ntabulations-2 \nlines-3\n");
- scanf("%d",&num);
- if(num<1 || num>3){
- printf("Enter number between 1 and 3\n");
- scanf("%d",&num);
- }
- if(num<=2){
- n=number(num);
- printf("in total %d\n",n);
- }
- if(num=3){
- n=number(num);
- printf("%d\n",n-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