Link to home
Start Free TrialLog in
Avatar of rbp
rbp

asked on

VC++ 1.52; problems with argc, **argv

I am on Windows NT4.0, but forced to use VC++ 1.52 for an application which uses 16 bit database access programs.  I am attempting to process a list of stock ticker symbols.  When I try this in VC++ 4.0 I can access at least 700 symbols.  When I do it in VC++ 1.52 I can only access 30.  If I try to access more than 30, the program crashes.  It doesn't even get to the line that prints argc-1.

I have never run into this before and I am at a loss as to what is causing it, although I suspect it might have somethng to do with the libraries that are being selected by the project builder.

Here is the simple program I am using for testing:

/*
      sample.cpp
      
      These examples will demonstrate how to use the
      Quotes Plus dll to read all of the price and
      fundamental data that we have.

      The functions automatically open all of the Quote
      Plus files when called, and close the files on exit.

*/

#include <stdio.h>
#include <string.h>


FILE *fp;

void main(int argc, char **argv)
{
      #define LEN 9
      char out[] = "C:\\tmp\\n.p";
      char sym[LEN];
      int i;

      printf ("The number of arguments is %d.\n", argc-1);

      fp = fopen( out, "w" );
      if ( !fp ) {
            printf ("Could not open %s.\n", out);
            return;      // Could not open it.
      } else printf ("Opening %s for writing.\n", out);

      printf ("The output file is %s.\n", out);
 

      while (--argc > 0) {

            strcpy(sym, *++argv);
            i = strlen(sym);
            while (++i < LEN)
                  sym[i] = ' ';
            sym[LEN] = '\0';

            fprintf (fp, "%s\n", sym);
      }

      fclose( fp );

}

Here are the library definitions from the makefile generated by the project builder for this test, except that I replaced mlibcew with mlibcewq in order to access printf:

CFLAGS_D_WEXE = /nologo /W3 /FR /G2 /Zi /D_DEBUG /Od /AM
      /GA /Fd"SAMPLE.PDB"
CFLAGS_R_WEXE = /nologo /W3 /FR /O1 /DNDEBUG /AM /GA
LFLAGS_D_WEXE = /NOLOGO /NOD /PACKC:61440 /STACK:1024
      /ALIGN:16 /ONERROR:NOEXE /CO  
LFLAGS_R_WEXE = /NOLOGO /NOD /PACKC:61440 /STACK:10240
      /ALIGN:16 /ONERROR:NOEXE  
LIBS_D_WEXE = mafxcwd oldnames libw mlibcewq commdlg.lib
      olecli.lib olesvr.lib shell.lib
LIBS_R_WEXE = mafxcw oldnames libw mlibcewq commdlg.lib
      olecli.lib olesvr.lib shell.lib
RCFLAGS = /nologo
RESFLAGS = /nologo

Here are the library definitions from the original program where I first encountered this problem:

CFLAGS_D_WTTY = /nologo /G2 /Zp1 /Mq /W3 /Zi /AL /Od /D
      "_DEBUG" /FR /Fd"SAMPLE.PDB"
CFLAGS_R_WTTY = /nologo /Gs /G2 /Mq /W3 /AM /Ox /D "NDEBUG"
      /FR
LFLAGS_D_WTTY = /NOLOGO /NOD /PACKC:57344 /ALIGN:16
      /ONERROR:NOEXE /CO
LFLAGS_R_WTTY = /NOLOGO /NOD /PACKC:57344 /ALIGN:16
      /ONERROR:NOEXE
LIBS_D_WTTY = lafxcwd llibcewq read11dl.lib oldnames libw
LIBS_R_WTTY = mafxcw mlibcewq oldnames libw read11dl.lib
RCFLAGS = /nologo
RESFLAGS = /nologo

Note that the original makefile was provided by the vendor and maintained unchanged, while the test makefile was built by the project builder and the only change was to replace mlibcew with mlibcewq.  For some reason the project builder assigns mlibcew but mlibcew does not have printf.  I don't understand that either.

If anybody can tell me why this program croaks at the 31st input arg, I would greatly appreciate it.

Bob
ASKER CERTIFIED SOLUTION
Avatar of jhance
jhance

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial