The following program takes two command line arguments.
I want the second argument (fileCount) to be stored/printed as a int value. I tried my best to typecast the char to int (check the printf statement at last) but is not working...the output is some junk value.
This program is in its beginning stage....this program is expected to take 2 list of strings along with the list count from files generated by a shell script and compare them both for equality ( & also checking for any extra or missing items using C++ hash functions (dictionary search) ) so the input is supposed to be the file name and list item count...the shell script is ready but...i am stuck up with the typecast for converting char to int...kindly help....& thanks in advance...........
#include <iostream>
using namespace std;
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <search.h>
#define SIZ 100 // Dictionary size
#define ARGCNT 3 // Argument count
//------------------------------------------------------------------------------
// GLOBAL
//char *str[SIZ];
FILE *fp;
char *fileCount;
char *fileList;
//------------------------------------------------------------------------------
// FILE PROCESSOR
//------------------------------------------------------------------------------
// MAIN
main( int argc,
char *argv[])
{
int i;
if ( argc < ARGCNT ) {
printf ("Invalid number of arguments.\n");
printf ("BASIL B.C. 2008.\n");
exit(1);
}
for (i=1;i<argc;i++) {
switch (i) {
case 1:
fileList = argv[i];
break;
case 2:
fileCount = argv[i];
break;
default:
printf ("Not implemented yet !.\n");
printf ("BASIL B.C. 2008.\n");
}
}
printf("%s %d\n",fileList,*((int *) fileCount));
return 0;
}