Click here to Skip to main content
15,889,216 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: programmer Pin
Eugen Podsypalnikov27-Sep-10 11:42
Eugen Podsypalnikov27-Sep-10 11:42 
GeneralRe: programmer Pin
Alan Balkany28-Sep-10 4:16
Alan Balkany28-Sep-10 4:16 
AnswerRe: programmer Pin
jeron127-Sep-10 11:33
jeron127-Sep-10 11:33 
Question"return 0" in user defined function Pin
AmbiguousName27-Sep-10 8:36
AmbiguousName27-Sep-10 8:36 
AnswerRe: "return 0" in user defined function Pin
Phil J Pearson27-Sep-10 9:00
Phil J Pearson27-Sep-10 9:00 
AnswerRe: "return 0" in user defined function Pin
pjdriverdude27-Sep-10 9:02
pjdriverdude27-Sep-10 9:02 
AnswerRe: "return 0" in user defined function Pin
Maximilien27-Sep-10 9:08
Maximilien27-Sep-10 9:08 
Questionchar data type problem Pin
pjdriverdude27-Sep-10 7:20
pjdriverdude27-Sep-10 7:20 
I have a method that will take in a char data type if I build it with the methods shown below. If I manually put the template into the variable, it runs fine, but when I build it, it craps out (I never know what the name of the user is, so I have to build the template with just a name given).

char voice_template_g[26] = "" ; //global

void initiate_voice_rec(char* voice_template) { //this would be a size 5-8 character set

	strncpy ( voice_template_g, voice_template, sizeof( voice_template_g ) ) ;
}


//later in the program, I check to see if a template exists.	


void get_current_voice_template() {

	char template_file_path[100] = "c:\\Dragon\\Speaker\\" ; //default file path
	char default_template[100] = "c:\\Dragon\\Speaker\\IPART" ; //default template file path
	char temporary_file_path[100] = ""; //use this to build the string

	strncat( temporary_file_path,
		 template_file_path,
		 sizeof( temporary_file_path ) ) ; //add the temporary_file_path to the temp_file_path



	strncat( temporary_file_path,
		 voice_template_g,
		 sizeof( temporary_file_path ) ) ; //add the voice template (from above) to the file path

	// if the directory exists, point to the logged in user's directory
	if( !_chdir( temporary_file_path ) )
	{
                //make the template string
		strncpy( voice_template_g, 
			 temporary_file_path, 
			 sizeof(voice_template_g) ) ; //if the template is made here, it craps out
	}
	else // use the default template
	{
                //make the default file path string
		strncpy( voice_template_g, 
			 default_template, 
			 sizeof(voice_template_g) ) ; //if this is copied, it works fine
	}
}


now if a template is made (not the default) it crashes, but if I call:

strncpy( voice_template_g, "c:\\Dragon\\Speaker\\TERR2285", sizeof( voice_template_g ) ) ; 


right at the end of get_current_voice_template(), it works fine.

is there a difference in the data used between:

strncpy( voice_template_g, temporary_file_path, sizeof(voice_template_g) ) ; 


and

strncpy( voice_template_g, "c:\\Dragon\\Speaker\\TERR2285", sizeof( voice_template_g ) ) ; 


They produce the same string, but they both don't work!
AnswerRe: char data type problem Pin
Luc Pattyn27-Sep-10 7:53
sitebuilderLuc Pattyn27-Sep-10 7:53 
QuestionRe: char data type problem Pin
David Crow27-Sep-10 8:30
David Crow27-Sep-10 8:30 
AnswerRe: char data type problem Pin
pjdriverdude27-Sep-10 8:55
pjdriverdude27-Sep-10 8:55 
QuestionRe: char data type problem Pin
David Crow27-Sep-10 9:00
David Crow27-Sep-10 9:00 
AnswerRe: char data type problem Pin
pjdriverdude27-Sep-10 9:04
pjdriverdude27-Sep-10 9:04 
QuestionRe: char data type problem Pin
David Crow27-Sep-10 9:05
David Crow27-Sep-10 9:05 
AnswerRe: char data type problem Pin
pjdriverdude27-Sep-10 9:33
pjdriverdude27-Sep-10 9:33 
GeneralRe: char data type problem Pin
David Crow27-Sep-10 9:35
David Crow27-Sep-10 9:35 
AnswerRe: char data type problem Pin
Aescleal27-Sep-10 8:33
Aescleal27-Sep-10 8:33 
GeneralRe: char data type problem Pin
pjdriverdude27-Sep-10 8:57
pjdriverdude27-Sep-10 8:57 
GeneralRe: char data type problem Pin
Luc Pattyn27-Sep-10 10:19
sitebuilderLuc Pattyn27-Sep-10 10:19 
AnswerRe: char data type problem Pin
Stefan_Lang29-Sep-10 6:51
Stefan_Lang29-Sep-10 6:51 
GeneralRe: char data type problem Pin
pjdriverdude1-Oct-10 5:31
pjdriverdude1-Oct-10 5:31 
GeneralRe: char data type problem Pin
Stefan_Lang3-Oct-10 22:50
Stefan_Lang3-Oct-10 22:50 
Questionis mfc coding diff [Moved] Pin
prithaa27-Sep-10 3:35
prithaa27-Sep-10 3:35 
AnswerRe: is mfc coding diff Pin
bob1697227-Sep-10 4:16
bob1697227-Sep-10 4:16 
GeneralRe: is mfc coding diff Pin
prithaa27-Sep-10 6:27
prithaa27-Sep-10 6:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.