answersLogoWhite

0

Look at the "wc" command's man page, it will give you a count of all characters, including the newline character.

User Avatar

Wiki User

16y ago

What else can I help you with?

Continue Learning about Engineering

How do you find the no of characters and numerics in the given string?

First of all numbers are not meant to be stored in a string and if u do so in C, these numbers will be treated as characters and you can not perform any calculation on these numbers, and to find the number of characters in a string use the strlen() from the string.h file.


Write a C program to extract a given word from a file?

program to extract a given word from a file


How will be the c program for reversing first n characters in a file?

#include <stdio.h> #include <conio.h> #include <string.h> #include <process.h> void main(int argc, char *argv[]) { char a[15]; char s[20]; char n; int k; int j=0; int i; int len; FILE *fp; if(argc!=3) { puts("Improper number of arguments."); exit(0); } fp = fopen(argv[1],"r"); if(fp == NULL) { puts("File cannot be opened."); exit(0); } k=*argv[2]-48; n = fread(a,1,k,fp); a[n]='\0'; len=strlen(a); for(i=len-1;i>=0;i--) { s[j]=a[i]; printf("%c",s[j]); j=j+1; } s[j+1]='\0'; getch(); }


How do you detect an empty file in a c program?

Seek to the end of the file (fseek) and check how many bytes are in the file If the byte count is zero the file is empty.


Write a c program To count number of words in a given string?

#include<stdio.h> #include<string.h> void main() { int count,i,len; char str[100]; printf("enter the sentence"); gets(str); len=strlen(str); for(i=0;i<=len;i++) { while(str) if(str[i]==' ') count++; } printf("the number of words are :\t%d",count+1); }

Related Questions

What does wc mean in ubuntu?

wc is the word count utility. wc <file name> would return four values number of lines, number of words, number of characters, filename of the file processed


By using awk programming how to count number of lines in a given file without wc command?

Use the following:awk 'END { print NR }'Awk will count the lines and print it out.


Write a shell script to count the number of times is appears in a given text file?

You don't need a shell script to do this; use the 'grep' command with the '-c' option to count the number of occurrences of some pattern.


How do you find the no of characters and numerics in the given string?

First of all numbers are not meant to be stored in a string and if u do so in C, these numbers will be treated as characters and you can not perform any calculation on these numbers, and to find the number of characters in a string use the strlen() from the string.h file.


For your operating system find the maximum number of characters you can use for a file name?

The maximum number of characters allowed for a file name varies by operating system. For example, in Windows, the maximum file name length is 260 characters, including the path. In contrast, most Linux filesystems allow file names up to 255 characters. It's important to note that these limits can be affected by the file system being used.


What is a data file that uses the same number of characters for each field in a data called?

It can be called a Fixed-Length file.


The term given to an asterisk or other character used to substitute for several characters in a file search?

Wild card


How do you write a c program that counts number of blanks in a text file using standard io?

int count_whitespace (FILE* input) { int c, count=0; while (( c = getc(input) ) != EOF ) if ((char) c==' ') ++count; return count; }


What characters can file names contain?

a file name can contain any type of character, it can be start from any character,number& can start with symbol also.


How do you find number of words in a file NOTE if there is more than one space between the words in the file it should not consider tat as a word?

count very carefully. . .


How many characters can be in a file name using Windows 95?

Windows 95 supported file names up to 255 characters in length.


What is the c program to count the no of digits in the given file?

Open the file for reading then traverse the file one character at a time. Each time you encounter a character within the range '0' through '9', increment a zero-initialised counter. When you reach the end of the file, close the file and return the counter value. int count_digits (const char* fname) { // Returns -1 on error (test global errno for system-specific errors). FILE* f; int count; char c; // Open file for read-only access (text-mode by default). FILE* f = fopen (fname, "r"); if (f==NULL) return (-1); count = 0; // Read and test each character, incrementing the count whenever the character is a digit. while (fscanf (f, "%d", &c) == 1) if (c>='0' && c<='9') ++count; fclose (f); return count; }