By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,441 Members | 1,831 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,441 IT Pros & Developers. It's quick & easy.

Reading char* word by word

P: n/a
Hi!
Is there possibility to read char* table word by word in C (not C++)?
I'm learning C by writing simple HTTP Server on BSD sockets (just for
fun). And I want to read info from HTTP header received from client. I
get char table, and I have to read some information.
Can you help me?

I can post the whole code of server when I finish.
Aug 20 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On Aug 20, 12:33*pm, Stuudent <wojtek.jurkowlan...@gmail.comwrote:
Hi!
Is there possibility to read char* table word by word in C (not C++)?
I'm learning C by writing simple HTTP Server on BSD sockets (just for
fun). And I want to read info from HTTP header received from client. I
get char table, and I have to read some information.
Can you help me?

I can post the whole code of server when I finish.
First you have to define what you want "word" to mean.
For example, what is the second "word" in this line:
<BODY TEXT="#000000" BGCOLOR="#FFFFFF">
is it BODY, or TEXT, or TEXT="#000000", or something else?
if you want it to be TEXT, what is the next "word"?
Is it
="#000000"
or
#000000

--
Fred Kleinschmidt
Aug 20 '08 #2

P: n/a
On 20 Sie, 23:05, Fred <fred.l.kleinschm...@boeing.comwrote:
On Aug 20, 12:33*pm, Stuudent <wojtek.jurkowlan...@gmail.comwrote:
Hi!
Is there possibility to read char* table word by word in C (not C++)?
I'm learning C by writing simple HTTP Server on BSD sockets (just for
fun). And I want to read info from HTTP header received from client. I
get char table, and I have to read some information.
Can you help me?
I can post the whole code of server when I finish.

First you have to define what you want "word" to mean.
For example, what is the second "word" in this line:
* *<BODY TEXT="#000000" BGCOLOR="#FFFFFF">
is it BODY, or TEXT, or TEXT="#000000", or something else?
if you want it to be TEXT, what is the next "word"?
Is it
* ="#000000"
or
#000000

--
Fred Kleinschmidt
Second word is ' TEXT="#000000 '
word separated by space or \n.
Aug 20 '08 #3

P: n/a
Stuudent wrote:
Hi!
Is there possibility to read char* table word by word in C (not C++)?
I'm learning C by writing simple HTTP Server on BSD sockets (just for
fun). And I want to read info from HTTP header received from client. I
get char table, and I have to read some information.
Can you help me?
You may look at the strtok function.
--
Pietro Cerutti
Aug 20 '08 #4

P: n/a
"Fred" <fr*****************@boeing.comwrote in message
news:bb**********************************@a3g2000p rm.googlegroups.com...
On Aug 20, 12:33 pm, Stuudent <wojtek.jurkowlan...@gmail.comwrote:
>Hi!
Is there possibility to read char* table word by word in C (not C++)?
I'm learning C by writing simple HTTP Server on BSD sockets (just for
fun). And I want to read info from HTTP header received from client. I
get char table, and I have to read some information.
Can you help me?

I can post the whole code of server when I finish.

First you have to define what you want "word" to mean.
For example, what is the second "word" in this line:
<BODY TEXT="#000000" BGCOLOR="#FFFFFF">
is it BODY, or TEXT, or TEXT="#000000", or something else?
Such as 0x444F?

(ascii OD as word)

Aug 21 '08 #5

P: n/a
On Aug 20, 4:05 pm, Fred <fr*****************@boeing.comwrote:
On Aug 20, 12:33 pm, Stuudent <wojtek.jurkowlan...@gmail.comwrote:
Hi!
Is there possibility to read char* table word by word in C (not C++)?
I'm learning C by writing simple HTTP Server on BSD sockets (just for
fun). And I want to read info from HTTP header received from client. I
get char table, and I have to read some information.
Can you help me?
I can post the whole code of server when I finish.

First you have to define what you want "word" to mean.
Actually, HTTP already defines it. If you want to parse the request
line, for example, it's easy, since the three items are separated by
spaces. HTTP defines it as

Request-Line = Method SP Request-URI SP HTTP-Version CRLF

(Where SP means a space character, and CRLF means the sequence "\r\n"
in C.) See RFC 2616 for further details.

With this in mind, you can either parse it with strtok(), or simply go
through the buffer examining character by character.

<snip>

Sebastian

Aug 21 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.