From 9858e271720861315726765cf3aebbfa4ff14ca8 Mon Sep 17 00:00:00 2001 From: Xiangfu Liu Date: Sun, 30 May 2010 23:41:14 +0800 Subject: [PATCH] use argv[1] as filename Signed-off-by: Xiangfu Liu --- sdl-imageviewer.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sdl-imageviewer.c b/sdl-imageviewer.c index f6721ca..1b6bb7d 100644 --- a/sdl-imageviewer.c +++ b/sdl-imageviewer.c @@ -42,8 +42,8 @@ int main(int argc, char *argv[]) rightPressed, upPressed, downPressed; - char sFilename[255] = "\0", - sVersion[] = "0.2.1"; + char * sFilename; + char sVersion[] = "0.2.1"; double scale_x = 1.0, scale_y = 1.0, scale = 1.0; @@ -54,10 +54,17 @@ int main(int argc, char *argv[]) // Process command line if (argc != 2) { - fprintf (stderr, "\n imgv v%s. Syntax: imgv \n\n Hotkeys:\n 'f' fit to screen\n 'z' zoom at pixel level\n 'i' zoom in 'o' zoom out\n 'l' rotate left 'r' rotate right\n 'arrows' pan 'ESC' quit\n\n", sVersion); + fprintf (stderr, "\n" + " imgv v%s. Syntax: imgv \n\n" + " Hotkeys:\n" + " 'f' fit to screen\n" + " 'z' zoom at pixel level\n" + " 'i' zoom in 'o' zoom out\n" + " 'l' rotate left 'r' rotate right\n" + " 'arrows' pan 'ESC' quit\n\n", sVersion); exit (1); } - strncpy (sFilename, argv[1], 254); + sFilename = argv[1]; // Initialize the SDL library if (SDL_Init(SDL_INIT_VIDEO) < 0)