x86 Assembly

Moderators: None (Apply to moderate this forum)
Number of threads: 4563
Number of posts: 16029

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
How can I cuont The number of words in a file ? Posted by rambosoft on 23 Apr 2011 at 3:02 AM
How can I cuont The number of words in a file ?Using TASM
Report
Re: How can I cuont The number of words in a file ? Posted by AsmGuru62 on 23 Apr 2011 at 6:09 AM
I forgot TASM... sorry, but here is some pseudo-code:
open file
nbytes = get file size
token = 0
nwords = 0

repeat 'nbytes' times
{
	c = read one character from file
	if (c is a word character)
	{
		++token
		if (token is 1) ++nwords
	}
	else
	{
		token=0
	}
}
;
; Function to check if c is a word character
;
bool IsWordChar (c)
{
	if (c is underscore) return true;
	if (c is digit) return true;
	if (c is lowercase character) return true;
	if (c is uppercase character) return true;
	return false;
}

FASM is so much easier to use.
Report
Re: How can I cuont The number of words in a file ? Posted by rambosoft on 23 Apr 2011 at 8:35 AM
Thanks any way
Report
Re: How can I cuont The number of words in a file ? Posted by m34tb34t on 27 Apr 2011 at 2:40 AM
filesize in bytes divided by 2 == number of words in file...
LOL but seriously.
It depends on your definition of a word and on what type of file. You could simply scan for the value 20h (space) and count every one you see. But that would only work in very limited situations. AsmGuru got the general purpose algorithm up already...
Report
Re: How can I cuont The number of words in a file ? Posted by m34tb34t on 10 May 2011 at 12:25 AM
The best solution will depend on the type of file you are counting words from and how you want to define a word. ASCII vs. Unicode. MS-Word docs vs. PDF files. It can get quite elaborate.

ASCII is the easiest to count groups of english letters with.

I would inc my counter on the first encounter of A-Z or a-z and skip everything else until I found a space, then skip any space characters until I encountered another alphabet character. Inc my counter again, rinse and repeat 'till you reach the end of the file.
Report
Re: How can I cuont The number of words in a file ? Posted by avidwan on 12 Jan 2013 at 4:25 PM
how to write reverse a string program in c?
how to write Reverse string program source code using pointers in c programming language..?
Armstrong numbers in c?
palindrome numbers program in c?

***************************************************************



Programming Pad.com


***************************************************************
Report
Re: How can I cuont The number of words in a file ? Posted by avidwan on 12 Jan 2013 at 4:27 PM
how to write reverse a string program in c?
how to write Reverse string program source code using pointers in c programming language..?
Armstrong numbers in c?
palindrome numbers program in c?

***************************************************************



Programming Pad.com


***************************************************************
Report
Re: How can I cuont The number of words in a file ? Posted by avidwan on 12 Jan 2013 at 4:29 PM
how to write reverse a string program in c?
how to write Reverse string program source code using pointers in c programming language..?
Armstrong numbers in c?
palindrome numbers program in c?

***************************************************************



Programming Pad.com


***************************************************************



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.