|
From: Jason H. <jas...@bt...> - 2001-10-18 14:04:36
|
You are trying to access an argv member that doesn't exist, in the strcpy()
function. The array starts at zero so with an empty command line only
argv[0] will be valid and it will contain the name of the executable.
Jason.
----- Original Message -----
From: "Christian Wallukat" <Chr...@vo...>
To: "CPP-Maillinglist (E-Mail)" <dev...@li...>
Sent: Thursday, October 18, 2001 1:40 PM
Subject: [Dev-C++] Errorhandling
> Hi list,
>
>
> I try to write a little Dos-tool.
> If I want to get the parameters and the user has no parameters specified I
> get an exception.
>
> I think the error comes if i call strlen() with an empty string...
>
> How can i handle this error, has anyone an idea ????
>
>
>
> ----------------Schnipp---------------------
> //Get commandline
> strcpy(szDatei, argv[1]); // ** try argv[0]**
> for (nCount = 2; argc > nCount; ++nCount)
> {
> strcat(szDatei, " \0");
> strcat(szDatei, argv[nCount]);
> };
>
> //Check Commandline
> if (strlen(szDatei) <= 5)
> {
> printf("Wrong parameter !");
> };
> -------------------Schnapp------------------
>
>
> Thanx for help
>
>
> Chris
>
> Diese Mail wurde auf Viren überprüft.
> This mail was checked for virusses.
>
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|