Saturday, May 22, 2010

Plz help me to write a c program to print the number of lines,characters and words in the given string?

using arrays or string functions or other simple functions.


program should be in simple c language

Plz help me to write a c program to print the number of lines,characters and words in the given string?
I'll give you a few small hints.





For lines and words, think about what separates them. What separates one line from the next and search for that. In your searching, just count them up.





Same for words. Look at what separates words and search for them and count them up.





characters should be pretty obvious.
Reply:Get the book "Software Tools in Pascal" by Kernighan and Plauger.





Note that both Kernighan and Plauger are very much "heavyweights" in the C world. Look at how that problem (and others like it) are solved in Pascal -- and you will also understand the "why" of many of C's design points.





If you just want a quick fix solution, wc.c is what you want (wc is a standard command on all Unix/Linux boxes -- it stands for "word count" and it counts lines, words and characters). I googled wc.c for you... the first reference is the wc utility (in C source) that is used in "busybox" (an all-purpose embedded program). I think its what you want -- have fun.





http://www.koders.com/c/fid4962C369E0520...
Reply:This sounds like a homework assignment.


If you're stuck, I'll help, but this is not a place to get people to do your homework.
Reply:Where is the input coming from?


No comments:

Post a Comment