I use Visual C++ 2005 Express to make programs with, and I'm generally rather new to C programming although, from another tool, I've known the basic syntax style for a long time. I'm trying to learn how to read and write files to automate a process I do with a hex edittor that is rather boring, time consuming, and prone to mistakes. I have two major issues, the big one being the "cannot convert char to const char" error involving strcat. Because I don't know how to convert an integer into a string without utilizing the number system, I figured I could just split the number into the digits 0 to 9 then add 48 to get the cooresponding digit character. I then thought of using strcat to stitch together these numbers to form the output, a file name (and path) in my case. This is where I'm stumped.

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

double sample_rate_base; // temporary for getting the fractional parts for rounding - 7 significant figures isn't quite enough given that sample rates go to 400,000
unsigned int sample_rate; // integerical rounded value of the above variable
signed short loop_position; // loop position for the creation of files
signed short loop_start; // starting point of the loop
signed short loop_end; // the point where the loop will end
unsigned int bytes_per_second; // equal to sample_rate*multiplier
char multiplier; // the multiplier used for the bytes_per_second variable
char file_head_start[24]; // for copying identical file header data
char file_head_end[7]; // for copying the last parts of the file header data
unsigned int file_length; // the length of the file after the header data in bytes
char file_contents[]; // the contents of the file for copying, since the samples themselves don't change at all
char file_name[]; // the file name for the output file

FILE *file_pointer;

void find_next_sample_rate()
{
	// Based on the new 48-step speed system
	if (loop_position < -72)
	{
		sample_rate_base += (208.0+(1.0/3.0)); // 208 1/3
	}

	if (loop_position == -72)
	{
		sample_rate_base = 17500.0; // a special case to prevent rounding flaws from the float - I may need the double
	}
	
	if ((loop_position > -72) && (loop_position <= -48))
	{
		sample_rate_base += 312.5;
	}
	
	if ((loop_position > -48) && (loop_position <= -24))
	{
		sample_rate_base += (416.0+(2.0/3.0)); // 416 2/3
	}
	
	if ((loop_position > -24) && (loop_position <= 0))
	{
		sample_rate_base += 625.0;
	}
	
	if ((loop_position > 0) && (loop_position <= 24))
	{
		sample_rate_base += (833.0+(1.0/3.0)); // 833 1/3
	}
	
	if ((loop_position > 24) && (loop_position <= 48))
	{
		sample_rate_base += 1250.0;
	}
	
	if ((loop_position > 48) && (loop_position <= 72))
	{
		sample_rate_base += (1666.0+(2.0/3.0)); // 1666 2/3
	}
	
	if ((loop_position > 72) && (loop_position <= 96))
	{
		sample_rate_base += 2500.0;
	}
	
	if ((loop_position > 96) && (loop_position <= 120))
	{
		sample_rate_base += (3333.0+(1.0/3.0)); // 3333 1/3
	}
	
	if (loop_position > 120)
	{
		sample_rate_base += 5000.0;
	}
	
	loop_position += 1; // advance the loop position
	sample_rate = (int)(sample_rate_base+0.5); // use starting value first and round it off
	bytes_per_second = sample_rate*multiplier;
}

void get_new_file_name()
{
	// chars 48 through 57 are the numbers
	char digit_1;
	char digit_10;
	char digit_100;
	char digit_1000;
	char digit_10000;
	char digit_100000;
	int remaining_part;
	
	digit_100000 = sample_rate/100000; // since integers are used, and junk after the decimal is ignored, only a single digit is present - breaks up numbers from 12500 to 400000 into digits
	remaining_part = sample_rate-(100000*digit_100000); // gets rid of the 100,000's digit leaving 5 digits left
	digit_100000 += 48; // shifts the digit value into the cooresponding character on the character map since 48 through 57 (decimal) are the digits
	digit_10000 = remaining_part/10000; // continue splitting the number into the separate digits
	remaining_part -= (10000*digit_10000);
	digit_10000 += 48;
	digit_1000 = remaining_part/1000;
	remaining_part -= (1000*digit_1000);
	digit_1000 += 48;
	digit_100 = remaining_part/100;
	remaining_part -= (100*digit_100);
	digit_100 += 48;
	digit_10 = remaining_part/10;
	remaining_part -= (10*digit_10);
	digit_10 += 48;
	digit_1 = remaining_part;
	digit_1 += 48;
	
	digit_100000 = (const char)digit_100000; // random test
	strcpy(file_name, "C:\\My Documents\\Songs for MP3\\Desert Zone\\");
	
	if (loop_end >= 48) // if the highest possible is 100,000 or greater, add a sixth digit
	{
		strcat(file_name, digit_100000); // a special case - write only if base sample rate is 6 or more digits but write the leading 0
	}
	
	strcat(file_name, digit_10000); // add the main common digits to the file name that are always present
	strcat(file_name, digit_1000);
	strcat(file_name, digit_100);
	strcat(file_name, digit_10);
	strcat(file_name, digit_1);
	strcat(file_name, " Desert Zone.wav\0"); // add the space at the end with the null character terminating the string
}

void create_output_files()
{
	/*
	notes about loop ranges (based of of the spreadsheet document):
	-96, 12500 Hz
	-84, 15000 Hz
	-72, 17500 Hz
	-64, 20000 Hz (extended minimum 50K)
	-56, 22500 Hz (rarely used)
	-48, 25000 Hz (standard minimum 50K)
	-36, 30000 Hz (100K)
	-24, 35000 Hz (100K)
	-16, 40000 Hz (extended minimum 100K)
	 -8, 45000 Hz (100K)
	  0, 50000 Hz (standard minimum 100K)
	 15, 62500 Hz (standard maximum 50K)
	 24, 70000 Hz (extended maximum 50K)
	 32, 80000 Hz (50K)
	 40, 90000 Hz (50K)
	 48, 100000 Hz (50K)
	 63, 125000 Hz (standard maximum 100K)
	 72, 140000 Hz (extended maximum 100K)
	 80, 160000 Hz
	 88, 180000 Hz
	 96, 200000 Hz
	108, 240000 Hz
	120, 280000 Hz
	128, 320000 Hz
	136, 360000 Hz
	144, 400000 Hz
	*/

	// first, set the range using the chart commented out above
	
	char temp_var;
	
	loop_start = -48; // starting point
	loop_end = 15; // ending point
	loop_position = loop_start; // start at the loop starting point
	sample_rate = 25000; // copy sample rate from chart above with loop_position as the value to take from
	bytes_per_second = sample_rate*multiplier;
	
	while(loop_position <= loop_end) // should create 64 files
	{
		printf("Current progress:  %d Hz, %d of %d processed\n", sample_rate, loop_position-loop_start, loop_end-loop_start);
		scanf("%d", &temp_var); // to stop input to see results for testing
		get_new_file_name(); // get the strings stitched together for the output file name
		/*
		file_pointer = fopen(file_name, "wb"); // open the file for writing in binary mode (WAV files are binary)
		fwrite(file_head_start, 1, 24, file_pointer); // write the details in the same order as it was read in
		fwrite(sample_rate, 4, 1, file_pointer);
		fwrite(bytes_per_second, 4, 1, file_pointer);
		fwrite(multiplier, 1, 1, file_pointer);
		fwrite(file_head_end, 1, 7, file_pointer);
		fwrite(file_length, 4, 1, file_pointer);
		fwrite(file_contents, 1, file_length, file_pointer); // copies all the rest of the data, the samples themselves
		fclose(file_pointer); // close the file to reuse the pointer (or is it handle as with Gamestudio?)
		*/
		
		loop_position += 1; // increment the loop for another round
		find_next_sample_rate();
	}
}

void read_base_file()
{
	// this copies the full structure of the WAV file, since only 8 bytes are changed out of several million
	/*
	file_pointer = fopen("C:\\My Documents\\Songs for MP3\\Desert Zone\\Desert Zone base.wav", "rb"); // assign a pointer (or handle?) for handling the file
	fread(file_head_start, 1, 24, file_pointer); // read into file_head_start in one-byte chunks and fill the array of 24 elements with the given file pointer
	fread(sample_rate, 4, 1, file_pointer); // same as above but read a 4-byte chunk once instead
	fread(bytes_per_second, 4, 1, file_pointer); // same as above
	fread(multiplier, 1, 1, file_pointer); // read a one-byte chunk once instead of the above
	fread(file_head_end, 1, 7, file_pointer); // read a one-byte chunk 7 times to fill the file header data's end
	fread(file_length, 4, 1, file_pointer); // read the file length data value, the number of bytes after the head
	fread(file_contents, 1, file_length, file_pointer); // read one-byte chunks for the entire file's length, which is the end of the file
	fclose(file_pointer); // close the file
	*/
	
	create_output_files(); // initiate the loop for creating the output files copying the data above changing the 8 bytes as needed
}

int main()
{
	read_base_file();
}
The get_new_file_name() function is where the errors are occurring due to strcat. strcpy works just fine (no errors nor warnings), but it's the part of stitching the numbers from the process above it together to form the end result.

The file-related instructions are commented out as I first want to test to see if the other parts work as they should. Once I finish that, fixing any bugs, I'd then test the file inputs.

What I'm trying to do is generate several WAV files with only the "sample rate" and "bytes per second" values changed (as to change the speed without any degradation; a mere 8 bytes). I currently do this using a hex edittor and I don't have any problems with that (as the results play back without any trouble). Only 8 bytes in the entire file get changed. The sample rate varies from 12500 Hz to as high as 400,000 Hz at the extreme ends, both of which play back just fine. Since only 8 bytes change, I figure it'd be better to just load the contents of the base file into memory (the source) then write the outputs with only the 8 bytes changed accordingly. The second thing I'm concerned about is whether or not I used the file instructions properly. That is, when a file is opened, it starts at the first byte of the file and after each read or write instruction, it advances accordingly. That is, if 24 bytes were read followed by an instruction to read a group of 4 bytes, it would read at the 25th byte rather than go back to the first byte. The file is closed to allow for reusing the handle or pointer (not sure which it is - it's a handle in my other tool I used which is very limited) for another file. The code should generate 64 WAV files of the same file size as the source, a bit over 46 MB.