[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: [PROGRAMMERING] sprintf problem



> On 2008-10-03, Christian G. V. Bøgh <sslug@sslug> wrote:
>> int main (int argc, char *argv[]) {
>>    unsigned char systemCmd[50];
>>    sprintf(systemCmd, "mount / –o,sync,remount");
>>    printf("systemCmd = %s\n", systemCmd);
>>    system(systemCmd);
>> }
>>
>>
>> Som giver dette output:
>> \$ ./FileTest
>> systemCmd = mount / o,sync,remount
>> mount: mounting / on o,sync,remount failed: No such file or directory
>>
>>
>> Problemet er at det '-' der står i sprintf forsvinder. Jeg har prøvet
>> denne konstruktion i stedet:
>>
>>    sprintf(systemCmd, "mount / ");
>>    strcat(systemCmd, "–");
>>    strcat(systemCmd, "o,async,remount");
>>    printf("systemCmd = %s\n", systemCmd);
>>    system(systemCmd);
>>
>> men med samme resultat. Det frostår jeg ikke!
>> Er der nogen der har en god forklaring på det?
>
> Det er ikke en '-' men et grimt unicode-tegn der ligner til forveksling,
> i hvert fald i det du har indsat her.
>
> /Sune
>

Ja, det er rigtigt. Jeg har brugt en Windows baseret editor på et Samba
drev. Det er åbenbart ikke nogen god ide! Jeg har lige checket med vi og
der er mit '-' blevet til '<96>'. Jeg har rettet det i vi og nu virker det
som det skal.
Tak for det :)

/Christian

P.S.
Jeg har også fået det til at virke fra min Windows editor efter jeg
ændrede på font settings. Den stod til "SBCS/DBCS Source Windows".
Jeg har rettet det til "Unicode Source Windows" og så virker det.




 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2008-11-01, 02:01 CET [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] *