[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
 

sprintf problem



Hej

Jeg har følgende program.

#include <linux/input.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
#include <strings.h>



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?

M.v.h.
Christian G. V. Bøgh



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