i'm being able to call my text file from my c program but when coming to count the number of paragraphs in the text i can't find what i have to do so that my c program increments my counter by 1 it has to find and empty line.
this is my program

#include <stdio.h>

char filename[500];

int main(void)
{
FILE *f;
int count;

printf("Enter the Text file :\n");
gets(filename);

f=fopen ("filename","r");
if (!f) {
	return 1;
	}

else currentChar == "\n"
{
		(count+1);
	}

fclose(f) ;
getchar();
getchar();
return 0;
}

in desperate need of help

Using gets is a very bad idea; use fgets instead, both to read in the filename from stdin and to read the opened file a line at a time. If the length of a line read by fgets is one then it's a new line on its own (a paragraph by your definition) so you can increment your counter. It'd be wise to zero your counter before you start incrementing it.

If you get stuck implementing this then post your attempt but please use code tags to ensure your code remains properly formatted when you post it.

How do you recognize one paragraph from another? There is no standard way to separate paragraphs like there is to separate lines. So your first task is to clearly define what constitutes a paragraph.

Counting the number of '\n's is counting lines, not paragraphs. So you will have to think up something else or redefine the problem to count the number of lines in the file.

Getting a string line by line. If any line contains more than 20 characters, increase the counter. In this way, we can avoid counting a empty line because some people like to leave some empty lines to seperate one paragraph.

How do you recognize one paragraph from another? There is no standard way to separate paragraphs like there is to separate lines. So your first task is to clearly define what constitutes a paragraph.

Counting the number of '\n's is counting lines, not paragraphs. So you will have to think up something else or redefine the problem to count the number of lines in the file.

I think that counting the number of non-empty, printable lines should do the trick.

The start of a paragraph is indicated by beginning on a new line and ending without running to the next passage. Sometimes the first line is indented, and sometimes it is indented without beginning a new line.

Hey guys, the OP said

i can't find what i have to do so that my c program increments my counter by 1 it has to find and empty line.

The definition of a paragraph is not ambiguous. He defined it.

Comments
I thought so, too. Thanks.

Your lot don't know how to post code snipet for people that are new to C programming.. and learn to do proper documentation with your codes!

The code snippets you see in these forums is not necessarily intended for new programmers.

>>and learn to do proper documentation with your codes!
I agree that most of the programs in these forums lack adequate comments that explain what the functions do. But the code is written by students, not professionals.

You don't actually need to read in lines to count the paragraphs.
You can read using fread and look for double CR/LFs.
Note that you'll need to look for 0x0D and 0x0A, because '\n' won't work correctly with fread on Windows.

This article has been dead for over six months. Start a new discussion instead.