Salem, Thanks for the reply. However, login info is entered in user interface no windows console, it is passed in as the parameter. when buff char array got it, it will be like "domain\user". If I changed you code based on this scenario, it will not work,
#include <stdio.h>
#include <string.h>...