Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > wait until \n appears in string

Reply
Thread Tools

wait until \n appears in string

 
 
nobody
Guest
Posts: n/a
 
      10-25-2003
"Micah Cowan" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "nobody" <(E-Mail Removed)> writes:
>
> >IMHO "string" as such
> > in C doesn't exist (I don't count string *literal*).

>
> YHO is wrong, according to the standard:
>
> char foo[] = "a string";
>
> foo[] is now a string.
>
> char bar[7] = "string?";
>
> bar[] is not (no terminating null character).
>
> bar[6] = '\0';
>
> Now it is.
>

Yep. It's 7.1.1 in N869. What I had in mind (but failed to state) is that
IMHO they don't exist as data types, only as data (contiguous sequence
of chars terminated by "the first null character", and it's not even related
to OP's question (it was just in back of my mind few previous posts with
copying over not-allocated memory and/or via uninitialized pointer).


 
Reply With Quote
 
 
 
 
Dan Pop
Guest
Posts: n/a
 
      10-27-2003
In <bnd54t$95b$(E-Mail Removed)> Richard Heathfield <(E-Mail Removed)> writes:

>William Ahern wrote:
>
>> Robert Mens <(E-Mail Removed)> wrote:
>>> Hi,

>>
>>> how is it possible to check if an \n appears in a string to
>>> process the data before the \n and then stack up the following
>>> data until another \n appears?
>>>
>>> I need this for something with sockets to know when the data
>>> is complete

>>
>> There are no sockets in Standard C, which is the sole topic discussed
>> here. Standard C defines fgets(), which reads lines from a file pointer.
>> In Unix you can finagle a socket into a file pointer using fdopen(3).
>> Maybe there's an equivalent in Win32. You should post this question on a
>> Win32 newsgroup. If you are in fact using Unix, checkout
>> comp.unix.programmer.

>
>I've never heard such nonsense. The question is clearly on-topic, and the
>answer is simple: strchr.


It's a bit more complex, if you read OP's question carefully: the data
to be processed is not (or may not be) entirely available in a memory
buffer. To make the question topical, just assume that the data is
coming from a stream instead of a socket. And then, the question becomes:
how do I read lines of text from a stream? strchr is usually NOT the
answer...

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
Richard Heathfield
Guest
Posts: n/a
 
      10-27-2003
Dan Pop wrote:

> In <bnd54t$95b$(E-Mail Removed)> Richard Heathfield
> <(E-Mail Removed)> writes:
>
>>The question is clearly on-topic, and the
>>answer is simple: strchr.

>
> It's a bit more complex, if you read OP's question carefully: the data
> to be processed is not (or may not be) entirely available in a memory
> buffer. To make the question topical, just assume that the data is
> coming from a stream instead of a socket. And then, the question becomes:
> how do I read lines of text from a stream? strchr is usually NOT the
> answer...


The answer I gave was to (the first part of) the question he actually asked,
"how is it possible to check if an \n appears in a string" - strchr clearly
being the Right Answer - BUT I agree with you that there was more to the
question than that, which is why other replies elsethread were also
valuable to the OP.

--
Richard Heathfield : (E-Mail Removed)
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wait until Dialog closes and return value. thjomha@gmail.com Java 2 05-22-2005 04:38 AM
wait until Brad Smallridge VHDL 2 03-26-2005 01:34 PM
Please wait until the debuggee has finished loading, then try aga =?Utf-8?B?QnJpYW4gUnVwZXJ0?= ASP .Net 0 08-13-2004 04:11 AM
Reworded: Wait until button pressed Allan Bruce Java 0 06-15-2004 05:04 PM
wait until stored procedure is complete TJS ASP .Net 2 02-11-2004 02:22 PM



Advertisments