Thread: Issue reading program arguments

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,734
    Never mind, fixed it, now I just need to fix the source of the crash.

    Code:
    int ProcessArgv( int argc, char **argv )
    {
    	int a, i = -1, num = 0, err;
    
    	ECHO( l_alloc.errors, fprintf( l_alloc.errors, "ProcessArgv( %d, %p )\n", argc, (void*)argv ) );
    
    	for ( a = 0; a < argc; ++a )
    	{
    		char *arg = argv[a];
    
    		ECHO( l_alloc.errors, fprintf( l_alloc.errors, "Analysing argument '%s'\n", arg ) );
    
    		if ( !arg || arg[0] == '-' )
    		{
    			if ( num || i >= 0 )
    			{
    				err = ArgHasIssue( i, num, argv );
    
    				if ( err )
    					return ArgHadIssue( err, i, num, argv );
    			}
    
    			i = a;
    			num = 0;
    
    			continue;
    		}
    
    		++num;
    	}
    
    	if ( num || i >= 0 )
    	{
    		err = ArgHasIssue( i, num, argv );
    
    		if ( err )
    			return ArgHadIssue( err, i, num, argv );
    	}
    
    	return 0;
    }
    In case anyone wants to help me find the source of memory corruption that is causing the crash I'll be uploading my current code in a minute, I'll edit this post to contain the link after

    Edit: As promised, here's the link:

    Files * 148969b2657cb6a5650f6995ade9a0f133f18880 * Lee Shallis / glEngine * GitLab

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. reading in command line arguments
    By cooper1200 in forum C Programming
    Replies: 1
    Last Post: 05-20-2019, 09:11 AM
  2. Reading arguments from command-line
    By SafetyMark in forum C Programming
    Replies: 2
    Last Post: 10-27-2016, 04:30 PM
  3. Too few arguments issue...
    By pp00 in forum C Programming
    Replies: 3
    Last Post: 11-13-2012, 03:31 PM
  4. Reading terminal arguments
    By DenKain in forum C++ Programming
    Replies: 24
    Last Post: 10-07-2008, 04:37 PM
  5. Problems while reading arguments
    By Lost__Soul in forum C Programming
    Replies: 6
    Last Post: 05-06-2003, 01:02 AM

Tags for this Thread