I have some code that outputs like this:
void exec_prompt(char * usr_name, char * host_name)
{
printf(" %s::%s\n", usr_name, host_name);
return;
}
But the print out doesnt look as expected:
geisst::ALPHA-DT2
There is that space at the front of the string.
The usr_name variable is passed from the main function and is returned from the getenv() function. The host_name variable is passed from the main function with the use of the following function:
char * returnHost()
{
char hostname[1024];
hostname[1023] = '\0';
gethostname(hostname, 1023);
return hostname;
}
Maybe the getenv() function adds a space?
Any help or advice is appreciated and please be nice 😛
GeissT
The reason is that your format has a space: ” %s::%s\n”
Just change it to: