The UNIX Forums
"Join the Network of UNIX System Users"


 
Subject: clearing data in an array
gk_awadhiya
Newbie
Rank: 1



UID 158
Digest Posts 0
Credits 0
Posts 41
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 20, 2007 10:47 AM  Profile | P.M. 
clearing data in an array



clearing data in an array



how would i clear all data from an array? here is what i'm doing:

code:
while (1) {
        if ((numbytes = recv(sock2, buf, 100, 0)) == -1) {
                perror("recv");
        }
        printf("%s : %s", inet_ntoa(their_addr.sin_addr), buf);
}buf[] still has extra data in it, so when i print it, things from previous data is put in there.

of course, that is only the one part of the program, but it was unnecessary to put the entire program in the post


Top
marioland
Newbie
Rank: 1



UID 250
Digest Posts 0
Credits 0
Posts 7
Reading Access 10
Registered Apr 25, 2007
Status Offline
Post at Jun 20, 2007 10:47 AM  Profile | P.M. 
1. is 'buf' one hundred bytes long?

2. if so what happens when you receive one hundred bytes?
Top
 

 

All times are GMT, the time now is Mar 22, 2010 01:57 PM

Powered by Discuz! 5.0.0  © 2001-2006 UNIX Forums
Processed in 0.004725 second(s), 8 queries

Clear Cookies - Contact Us - UNIX Help - Archiver - WAP