#define LEGAL 1 

void count(char array[]);

int main()

	char line[100];

	printf("Hey user enter some lines : ");

/* FUNCTION count */

void count(char array[])
	char c;
	int x,z=0;
		/* Wat to do to count \n and \t and blanks */
			for(x = 0 ;(c = array[x]) != '\0' ; x++)

HElp me wid this function count..

wat i m trying to make is tat :-

this function will count the characters used and tell me in decimal format.

the main reason for making this function is that it will help in malloc();
function to allocate exact memory....

plzzzzzz help.................

and wen i am putting a space the loop terminates...
and shows only first charcters eg:-

if written:-

aneesh hi


6 characters...


I'd help, but reading your sloppy ass typing is too painful.

in your "count()" function within the body of the "for" loop, test if the character is a space ' '. if the character is a space, then break out of the for loop early by using the "break" command.

if you want to be thorough, test also for \newlines and \tabs

if (c == ' ' || c == '\n' || c == '\t')

finally, make a nominal effort to spell words correctly. you are not posting from a SMS texting cellphone, so typing "wut" and "wud" and "tat" and "wen" makes you look like a goddamn willful retard. If you do it anymore, i'm never going to help you again.


Edited 6 Years Ago by jephthah: n/a

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