[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



Hej

Man kan da bruge memset til at nulstille strengen, men skal data
behandles som en tegnstreng er det slet ikke nødvendigt. Jeg vil foreslå
at du ganske enkelt afslutter strengen når du læser den newline der
afslutter din while-løkke. Jeg indsætter den i din kode nedenfor.

På den måde vil den slutte ved det sidste tegn, når den behandles som
tegnstreng og hvad der står senere er ligemeget.

M.v.h.
Søren H. Sørensen

Bo Mangor 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++;
> }
> line[y]=0;    /* Så er din streng 0-termineret på c-vis */
 
> 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


 
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] *