C++ Help,formatting a file path
#1

Hello,im inneed of some help because i just cannot find the answer...
How do i format the directory of a file?I have this:

Код:
int main()
{
	printf("Total created accounts: %d\n\n",files);
	char Directory[64],Rasp[5],Nume[20],varsta,Localitate[20],Judet[20],Tara[20],Liceu[20];
	printf("Whats your name?\n");
	gets(Nume);
	printf("\n\nWant to create the file?\n");
	gets(Rasp);
	printf("D:/gamer/Accounts/%s",Nume);
	if(strcmp(Rasp,"Da") == 0)
	{
		FILE * pFile;
		pFile = fopen ("D:/gamer/Accounts/Number","w");//Directory should be a string.
		if (pFile!=NULL)
		{
			fputs ("Text",pFile);//ADD A STRING HERE
			fclose (pFile);
			files++;
		}
	}
	else
	{
		printf("Sucker");
	}
}
i want something like this:
pawn Код:
format(string,sizeof(string),"D:/Gamer/Accounts/%s",Nume);
pFile = fopen (string,"w");
Reply
#2

Usage format in C++
Reply
#3

Quote:
Originally Posted by CrunkBankS
Посмотреть сообщение
Usage format in C++
Unfortunatelly,format is not a C++ function,it is a SAMP one.
Reply
#4

You should really post at a C++ forum for stuff like this, but sprintf is the C++ equivalent of format.
Reply
#5

Quote:
Originally Posted by kc
Посмотреть сообщение
You should really post at a C++ forum for stuff like this, but sprintf is the C++ equivalent of format.
Thanks alot .I am sorry for posting here,im not going to post this type of topics here anymore.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)