C++ Beginner Problem With Optget

Hi. I am new to C++. But I am trying to write a basic program that uses the command line. But...
$ ./myscript -s 1 -e 8 -c billy -v 1 -o test

I get output like this...
Starting Length = 1 Ending Length = 8 Name = (null) Output File = (null) Verbose = 1

How come 'Name' and 'Output File' show (null)?

#include <iostream>
#include <cstring>

using namespace std;

int main(int argc, char *argv[])
{
	
	char *start_f;
	char *end_f;
	char *name_f;
	char *out_f;
	
	int verbose_f;
	int help_f;
	int arg;
	
	while((arg = getopt(argc, argv, "s:e:n:o:vh")) != -1)
		
		switch(arg) {
				
			case('s'):
				
				if(*optarg=='1'||*optarg=='2'||*optarg=='3'||*optarg=='4'||*optarg=='5'||*optarg=='6'||*optarg=='7'||*optarg=='8')
					start_f = optarg;
				
				else {
					cout << "ERROR!" << endl;
					return 0; }
				
				break;
				
			case('e'):
				
				if(*optarg=='1'||*optarg=='2'||*optarg=='3'||*optarg=='4'||*optarg=='5'||*optarg=='6'||*optarg=='7'||*optarg=='8')
					end_f = optarg;
				
				else {
					cout << "ERROR!" << endl;
					return 0; }
				
				break;
				
			case('n'):
				
				if(optarg=="billy")
					name_f = optarg;
							
				break;
				
			case('o'):
				
				out_f = optarg;
				
				break;
				
			case('v'):
				
				verbose_f = 1;
				
				break;
				
			case('h'):
				
				help_f = 1;
				cout << "ERROR!" << endl;
				return 0;
				
				break;
			
			default:
				cout << "ERROR!" << endl;
				return 0; }
	
	printf("\nStarting Length = %s    Ending Length = %s    Name = %s   Output File = %s    Verbose = %d\n\n",
		   start_f, end_f, name_f, out_f, verbose_f);
	
	return 0;
	
}

Are you sure you're entering "-c billy" and not "-n billy"?

Also, one of your lines:

if(optarg=="billy")

will result in undefined behaviour. Try changing it to "if (string(optarg)=="billy")" and see what happens.

You're using printf. you need to include <stdio.h>

Your program is a hairs-breath from being pure C, which has a few advantages. Replace cout with printf, if(string_object == other_string) with if(strcmp(cstring, othercstring) == 0) , get rid of the C++ iostream etc. includes and you'll be there, and be able to compile with gcc instead of g++ and enjoy the big improvement in compilation speed and decrease in executable size and runtime resource usage.