Code below,
basically if you run it it asks:
Please Enter The Full Path To Your File You Want To Copy To:
perfectly but Carries on running the IF without asking me the Second question. i've tried putting it in else if. but it does not like it either
Please help as im still learning.
basically if you run it it asks:
Please Enter The Full Path To Your File You Want To Copy To:
perfectly but Carries on running the IF without asking me the Second question. i've tried putting it in else if. but it does not like it either
Please help as im still learning.
PHP:
// Tester.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h> /* required for file operations */
#include <dos.h> /* for delay */
#include <cstdlib>
//Variables & Pointers
//Vars
char FileNamePath[256] = "test.txt";
char FileNamePathCopy[256] = "test2.txt";
enum {MAX_LEN = 100};
//Pointers
FILE *OPENFILE, *COPYFILE; /* declare the file pointer */
//Functions Are Crazy
void LineReadWrite(FILE *fin, FILE *fout)
{
char buff[MAX_LEN];
while(fgets(buff, MAX_LEN, fin) !=NULL)
{
fputs(buff, fout);
printf("%s",buff);
}
}
int _tmain(int argc, _TCHAR* argv[])
{
printf("Please Enter The Full Path To Your File You Want To Copy To:\n");
scanf_s("%c",FileNamePathCopy);
printf("Please Enter The Full Path To Your File\n");
scanf_s("%c",FileNamePath);
if((COPYFILE = fopen(FileNamePathCopy,"w")) == NULL) //should open file
{
printf("Cannot Find Your File: %s.\n Please Try Again",FileNamePathCopy); //cannot find file
}
else if
((OPENFILE=fopen (FileNamePath, "r+"))==NULL)
{
printf("Cannot Find Your File: %s.\n Please Try Again",FileNamePath);
}
else
{
LineReadWrite(OPENFILE,COPYFILE);
if(fclose(OPENFILE)==0)
printf("Closed the %s File Sucessfully\n", FileNamePath);
if(fclose(COPYFILE)==0)
printf("Closed the %s File Sucessfully\n", FileNamePathCopy);
}
system("pause");
return 0;
}