[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] initalisering i c



--- Bo Mangor <sslug@sslug> wrote:
> Hej
> 
> Håber der er en der kan hjælpe mig med et umiddelbart banalt spørgsmål!
> 
> Hvordan initialisere man et char array i c ??
> 
> Char line[50]  så det bliver en helt tom streng??
> 
> 
> Den bliver brugt til at modtage en kommando via læs fra socket
> 
> Char line [50];
> Char c;
> 
> while ( ch != '\n')
> {
> read (fd, &ch, 1);
> line[y] = ch;
> y++;
> }
> 
> fd = socket nr.
> 
> Strengen bliver brugt flere gange i træk og med tekster i forskellige
> længder + der kommer noget "fnider"  ind til sidst i strengen??
> 
> Håber der er en der vil forbarme sig! :)
> 
> Hej
> Bo Mangor

Jeg kender ikke til sockets, men du kan bruge fx. 
memset(&line[0],'\0',50*sizeof(char))
eller bare
memset(line,0,sizeof(line))
som jeg plejer at bruge.
Der er dog forskel på 0 og '\0' (som jeg mener sluttegnet hedder - jvf ascii-tabellen).



__________________________________________________
Do You Yahoo!?
Yahoo! Shopping - Thousands of Stores. Millions of Products.
http://shopping.yahoo.com/


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:08 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *