delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/06/20/12:10:54

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <82BCF2187EB8D54483F55F9FB210E44027521E@s099npex01.myInland.com>
From: "Pitts, Christopher (Inland)" <CPitts AT iccnet DOT com>
To: "'cygwin AT cygwin DOT com'" <cygwin AT cygwin DOT com>
Subject: sprintf question.
Date: Thu, 20 Jun 2002 11:10:16 -0500
MIME-Version: 1.0

I have, what I hope, is a easy question about sprintf under cygwin.

In a nutshell, it looks like system or sprintf is chopping off any
backslashes that get passed in.  Example below.

C:\work\COMPILER\ee>gcc -v
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/2.95.3-5/specs
gcc version 2.95.3-5 (cygwin special)


sprintfExample.c
----CUT HERE----
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    char backslashes[] = "C:\\winnt\\system32\\notepad.exe";
    char result[128];
    int retval;

    printf("printf says \"%s\"\n",backslashes);
    sprintf(result,"%s",backslashes);

    retval = system(result);

    return(0);
}
----END CUT----

compile it...
C:\work\COMPILER\ee>gcc sprintfRevision.c -o sprintf.exe

run it...
C:\work\COMPILER\ee>sprintf.exe
printf says "C:\winnt\system32\notepad.exe"
C:winntsystem32notepad.exe: not found


I've looked through the GNU LibC manual (PDF), the man pages, and the cygwin
docs, and I don't see any mention of this.
Am I just missing something easy?  Is this a bug?

If I change the 
char backslashes[] = "C:\\winnt\\system32\\notepad.exe";
to be 
char backslashes[] = "C:'\\'winnt'\\'system32'\\'notepad.exe";
it works as expected (fires up notepad).

What am I missing here guys?


C. Pitts


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019