[plug] C, bad syntax etc.
shayne at guild.murdoch.edu.au
shayne at guild.murdoch.edu.au
Tue Nov 19 12:27:22 WST 2002
Or failing that use python ;)
Erm. Not a c guru, but your general form is going to be;
(pseudocode)
For each line in file
{
For each character in line
{
if character in [1..9]
{
Perform some sorta action
}
}
}
Now keep in mind that thats the super unoptimised version.
The each-character-in-line bit can be done via a searchstring (or 0-9 search
strings if no regexp is available for the task. But that won't necessarily
help you for whole classes of problem.
What *exactly* is the prob your working on John?
Quoting Bret Busby <bret at busby.net>:
> On Tue, 19 Nov 2002, John Knight wrote:
>
> >
> > Cheers mate, don't worry, it's out of the loop. ;) Now I'm trying to
> figure
> > out how to search through text for numbers only! *groan* heh. ;)
> >
> >
>
> 1. using a switch statement for each case of 0,1,2,3,4,5,6,7,8,9, then
>
> the break?
>
> 2. using isnum ? (isalnum then isalpha)
> Could be done using #define to define macro isnum as
> (if(isalnum(variable_name) && if(!(isalpha(variable_name)))
> assuming that you are searching for numbers, as opposed to digits, in
> which case you have isdigit, and you could probably use
> while(isdigit(variablename)) to retrieve numbers
> ?
>
> ? here is not the conditional operator :)
>
>
> --
> Bret Busby
> Armadale
> West Australia
> ..............
>
> "So once you do know what the question actually is,
> you'll know what the answer means."
> - Deep Thought,
> Chapter 28 of the Hitchhiker's Guide to the Galaxy
> - Douglas Adams, 1988
> ....................................................
>
>
More information about the plug
mailing list