Sponsored Content
Top Forums Programming Simple C program to count word lengths Post 302983540 by Corona688 on Wednesday 12th of October 2016 06:22:31 PM
Old 10-12-2016
You are getting into the if(c == '\n') section with state as still OUT and thereby bypassing your ++maxlength[wl].

I don't think state serves any function at all though. You could dispose of it and just ignore anything with wordlengths of 0, for much simpler logic.
This User Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How do I count # of char. in a word?

I havent done shell scripting in quite some time. I want to know how to count the number of characters in a word, specifically a parameter. Example: myscript hello I want "myscript" to return the number of charcaters in the parameter "hello". Any ideas? (9 Replies)
Discussion started by: xadamz23
9 Replies

2. UNIX for Dummies Questions & Answers

count word

hi, given a file i need to get the first line and secodn line and count each of the line whether the length of first line and second line is the same i don;t know how to get the length of the line...seems like use 'wc' cannot do it... please advice (1 Reply)
Discussion started by: ariuscy
1 Replies

3. Shell Programming and Scripting

specified word count

hi iam trying to do a specified word count on file called text i have a few ideas but don't get the result i want do any one have a idea please help i have this at the moment cat text echo "Please enter the word you are looking for:" read string echo "the word < $string > occurs in... (5 Replies)
Discussion started by: bhaviknp
5 Replies

4. UNIX for Dummies Questions & Answers

Word Count

Hi All, Please let me know how to get the count of a particular word in a file. Example. I am looking for count of word 'result' in a file abc.xml. Thanks, Shankar (10 Replies)
Discussion started by: s_chowhan
10 Replies

5. Fedora

word count wc

could someone explain this please. echo aaaa|wc -c 5 echo aaaa|wc -m 5 But I'd expect the count to be 4 Its SunOS 5.8 Thanks in Advance. (5 Replies)
Discussion started by: chaandana
5 Replies

6. Shell Programming and Scripting

Word count of lines ending with certain word

Hi all, I am trying to write a command that can help me count the number of lines in the /etc/passwd file ending in bash. I have read through other threads but am yet to find one indicating how to locate a specifc word at the end of a line. I know i will need to use the wc command but when i... (8 Replies)
Discussion started by: warlock129
8 Replies

7. UNIX for Advanced & Expert Users

Word count

Script that lists all words used in one or more files and displays their count (pattern /\W+/ to split the lines of the input file into words can b used).. It should display list in format word:count...gets Filename as an cmd line argument! eg: $perl test doc (where doc is d file we are going to... (4 Replies)
Discussion started by: aadi_uni
4 Replies

8. Shell Programming and Scripting

if, word count

Hi, I need to count the lines of a file stack.html and if the amount lines i want to do something. At this moment, I have if ; then ... This is not working. Any ideas? Thanks! (3 Replies)
Discussion started by: azertyazerty
3 Replies

9. Shell Programming and Scripting

Word Count error

I need to read a trigger file whose name can be: ABC!DEF@2014.txt or ABC!DEF@2014,2015.txt and then carry out functions on those inputs. Currently I am doing: YEAREXPORT { FILE= xyz.txt ls ABC* -l > ${FILE} if ; then log_err "Trigger File ABC* does not exist!" fi (4 Replies)
Discussion started by: rajiv_kool
4 Replies

10. UNIX for Beginners Questions & Answers

UNIX script to check word count of each word in file

I am trying to figure out to find word count of each word from my file sample file hi how are you hi are you ok sample out put hi 1 how 1 are 1 you 1 hi 1 are 1 you 1 ok 1 wc -l filename is not helping , i think we will have to split the lines and count and then print and also... (4 Replies)
Discussion started by: mirwasim
4 Replies
cprof(3erl)						     Erlang Module Definition						       cprof(3erl)

NAME
cprof - A simple Call Count Profiling Tool using breakpoints for minimal runtime performance impact. DESCRIPTION
The cprof module is used to profile a program to find out how many times different functions are called. Breakpoints similar to local call trace, but containing a counter, are used to minimise runtime performance impact. Since breakpoints are used there is no need for special compilation of any module to be profiled. For now these breakpoints can only be set on BEAM code so s cannot be call count traced. The size of the call counters is the host machine word size. One bit is used when pausing the counter, so the maximum counter value for a 32-bit host is 2147483647. The profiling result is delivered as a term containing a sorted list of entries, one per module. Each module entry contains a sorted list of functions. The sorting order in both cases is of decreasing call count. Call count tracing is very lightweight compared to other forms of tracing since no trace message has to be generated. Some measurements indicates performance degradation in the vicinity of 10 percent. EXPORTS
analyse() -> {AllCallCount, ModAnalysisList} analyse(Limit) -> {AllCallCount, ModAnalysisList} analyse(Mod) -> ModAnlysis analyse(Mod, Limit) -> ModAnalysis Types Limit = integer() Mod = atom() AllCallCount = integer() ModAnalysisList = [ModAnalysis] ModAnalysis = {Mod, ModCallCount, FuncAnalysisList} ModCallCount = integer() FuncAnalysisList = [{{Mod, Func, Arity}, FuncCallCount}] Func = atom() Arity = integer() FuncCallCount = integer() Collects and analyses the call counters presently in the node for either module Mod , or for all modules (except cprof itself), and returns: FuncAnalysisList : A list of tuples, one for each function in a module, in decreasing FuncCallCount order. ModCallCount : The sum of FuncCallCount values for all functions in module Mod . AllCallCount : The sum of ModCallCount values for all modules concerned in ModAnalysisList . ModAnalysisList : A list of tuples, one for each module except cprof , in decreasing ModCallCount order. If call counters are still running while analyse/0..2 is executing, you might get an inconsistent result. This happens if the process executing analyse/0..2 gets scheduled out so some other process can increment the counters that are being analysed, Calling pause() before analysing takes care of the problem. If the Mod argument is given, the result contains a ModAnalysis tuple for module Mod only, otherwise the result contains one Mod- Analysis tuple for all modules returned from code:all_loaded() except cprof itself. All functions with a FuncCallCount lower than Limit are excluded from FuncAnalysisList . They are still included in ModCallCount , though. The default value for Limit is 1 . pause() -> integer() Pause call count tracing for all functions in all modules and stop it for all functions in modules to be loaded. This is the same as (pause({'_','_','_'})+stop({on_load})) . See also pause/1..3 below. pause(FuncSpec) -> integer() pause(Mod, Func) -> integer() pause(Mod, Func, Arity) -> integer() Types FuncSpec = Mod | {Mod,Func,Arity}, {FS} Mod = atom() Func = atom() Arity = integer() FS = term() Pause call counters for matching functions in matching modules. The FS argument can be used to specify the first argument to erlang:trace_pattern/3 . See erlang(3erl). The call counters for all matching functions that has got call count breakpoints are paused at their current count. Return the number of matching functions that can have call count breakpoints, the same as start/0..3 with the same arguments would have returned. restart() -> integer() restart(FuncSpec) -> integer() restart(Mod, Func) -> integer() restart(Mod, Func, Arity) -> integer() Types FuncSpec = Mod | {Mod,Func,Arity}, {FS} Mod = atom() Func = atom() Arity = integer() FS = term() Restart call counters for the matching functions in matching modules that are call count traced. The FS argument can be used to specify the first argument to erlang:trace_pattern/3 . See erlang(3erl). The call counters for all matching functions that has got call count breakpoints are set to zero and running. Return the number of matching functions that can have call count breakpoints, the same as start/0..3 with the same arguments would have returned. start() -> integer() Start call count tracing for all functions in all modules, and also for all functions in modules to be loaded. This is the same as (start({'_','_','_'})+start({on_load})) . See also start/1..3 below. start(FuncSpec) -> integer() start(Mod, Func) -> integer() start(Mod, Func, Arity) -> integer() Types FuncSpec = Mod | {Mod,Func,Arity}, {FS} Mod = atom() Func = atom() Arity = integer() FS = term() Start call count tracing for matching functions in matching modules. The FS argument can be used to specify the first argument to erlang:trace_pattern/3 , for example on_load . See erlang(3erl). Set call count breakpoints on the matching functions that has no call count breakpoints. Call counters are set to zero and running for all matching functions. Return the number of matching functions that has got call count breakpoints. stop() -> integer() Stop call count tracing for all functions in all modules, and also for all functions in modules to be loaded. This is the same as (stop({'_','_','_'})+stop({on_load})) . See also stop/1..3 below. stop(FuncSpec) -> integer() stop(Mod, Func) -> integer() stop(Mod, Func, Arity) -> integer() Types FuncSpec = Mod | {Mod,Func,Arity}, {FS} Mod = atom() Func = atom() Arity = integer() FS = term() Stop call count tracing for matching functions in matching modules. The FS argument can be used to specify the first argument to erlang:trace_pattern/3 , for example on_load . See erlang(3erl). Remove call count breakpoints from the matching functions that has call count breakpoints. Return the number of matching functions that can have call count breakpoints, the same as start/0..3 with the same arguments would have returned. SEE ALSO
eprof(3erl), fprof(3erl), erlang(3erl), User's Guide Ericsson AB tools 2.6.6.3 cprof(3erl)
All times are GMT -4. The time now is 08:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy