Thanks for the answers friends.
Im not a programming expert.. just learning by myself.
So forgive me if i made any mistakes in coding style.
After reading CPallini's answer I did a search for myfile.txt in my c: drive. and found the myfile.txt file in system32 folder.
Im confused coz my application placed in "c:\myApplication\HelloWorld.exe" but it writes the file in system32 folder.
So i thought of getting the current directory in coding. so i added some codes to detect the current application directory.
modified code.
#include <cstdlib>
#include <iostream>
#include <unistd.h>
using namespace std;
int main(int argc, char *argv[])
{
char *path=NULL;
size_t size;
path=getcwd(path,size);
cout<<"Current Path = "<<path<<"\n";
cout<<"Writing Hello World.\n";
FILE *file;
file=fopen("myfilekiruba.txt","a+");
if(file!=NULL)
{
fputs("Hello World!\n",file);
fclose(file);
cout<<"Succes!\n";
}
system("PAUSE");
return EXIT_SUCCESS;
}
After the system reboot. Application started and it showed "system32" folder as current directory. but my application not placed in system32 folder. and also i checked in system32 folder could not find my application.
here is the screenshot of the console window.
http://i780.photobucket.com/albums/yy87/kirubalks/Application.jpg[
^]
how to solve this problem.
@Aescleal.. Thanks friend. I tried your suggestion its working.
but how to solve this problem?
my application placed in somewhere & it is executing from system32 folder.
hope you guys can help me.
Thanks.