Computer Science Canada

Scanning whitespace

Author:  jamonathin [ Tue Mar 06, 2007 1:49 pm ]
Post subject:  Scanning whitespace

Anybody know how to scan whitespace?

I need to be able to scan something like
Quote:

Dear, world.

    
I hate you so very, very much.

    
    
Regards, Rosie O'Donnell


With the \n's and \t's in there. Thanks bunch.

Author:  md [ Tue Mar 06, 2007 3:02 pm ]
Post subject:  RE:Scanning whitespace

what do you mean by "scan"? If you mean parse a string, then yes it's super easy. If you mean remove whitespace, then that too is easy.

Author:  jamonathin [ Tue Mar 06, 2007 4:13 pm ]
Post subject:  Re: Scanning whitespace

Ah sry i ment with user input. How would i scanf/fgets something like that. Or if I were to have it in a file where i would do something like
Quote:

a.out < file.txt

Author:  md [ Tue Mar 06, 2007 7:59 pm ]
Post subject:  RE:Scanning whitespace

so you want to read in input including whitespace? The easiest way is just to read in characters and add them to a string. There are other ways involving reading entire lines and stuff, but those are slightly more complex.

Author:  jamonathin [ Tue Mar 06, 2007 8:22 pm ]
Post subject:  Re: Scanning whitespace

Ah, KISS.

Thanks md.

Author:  haskell [ Tue Mar 06, 2007 9:04 pm ]
Post subject:  RE:Scanning whitespace

This is C, right?

http://www.cplusplus.com/reference/clibrary/cstdio/fread.html

Author:  jamonathin [ Wed Mar 07, 2007 11:18 am ]
Post subject:  Re: Scanning whitespace

Yeah, thats C.


: