C/C++ :: Program To Copy A File From Source And Paste With Different Name

Mar 6, 2014

I have written a program that copies a file from the source and pastes it there (same location), but with a different name. The program works fine, except there is a small bug that i can't seem to fix. Here is the code:

/*
This program copies a file from the current directory and pastes it to the same directory, but with a different name. The file name form the source must include the extension as well.
*/

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
int main() {
char temp, s_file[100], d_file[100],

[Code] ....

This is the flow:

> 1) Enter the name of the file you'd like to copy (Must be from the current directory)
> A: 3.c // This depends if the file exists in the
> current directory
>
> 2) Enter the name of the destination file (The file will be copied to the same directory)
> A: 4 //The extension isn't necessary here
>
> Result: The file was copied successfully!

When I run the prg again, and this time input a file name with no extension, like this:

> Enter the name of the file you'd like to copy (Must be from the current directory)
> 3
> You did not enter a valid text. Press "?" to get help or "x" to exit.

I hit "?" and it takes me to

> 1. The file must be from the current directory)
> 2. The location mustn't be empty

Then it asks me

> Try again? (Y/N)

If i give N, it exits. BUT if I give Y, it goes, like this:

> Enter the name of the file you'd like to copy (Must be from the current directory)
> You did not enter a valid text. Press "?" to get help or "x" to exit.

You see, it doesn't give me the option to give it the file name..

View 3 Replies


ADVERTISEMENT

C++ :: Copy And Paste Function From Other Source Program Doesn't Wait For Input

Nov 27, 2013

I'm working on a project that requires to make modifications to certain functions. So, I'll copy and paste the function to a new source code so I'm just working on the function with the entire program running. When I run the function by itself, it works fine. But when I copy and paste the function back to it's spot, the program doesn't wait for input at the cin.getline & it did wait when I ran just the function by itself. I'm using Dev C++ if that makes a difference.

View 2 Replies View Related

C :: Best Way To Copy Paste A String Between Two Files

Jun 4, 2013

I have one tab seperated file and i whish to change values in one column and then copy the entire row (including the changed value) into anothe file.

file :

Code:
x y z sdfsdgnsdfgndfjgndfbsgdf
x y z dkjfgdsbfvgsdfvg
x y z ksdnfsdfbsdnfsdvjsdbvjsdjfnsdbfubsdfjsdbfuibsdfsdfujbsduf

the way i am doing it right now:

Code:
while (fgets(line, sizeof line, list) != NULL){
result = sscanf(line, "%ld %ld %d %10000s", &one,& two, &three,string);
if (results == 4){
// change three
//print: one two three string
}
}

the problem is that the string in the file is of variable size and sometimes it is bigger then my char string[10001] array which then i need to resize and it gets messy. Is there a way to somehow , once identified first three numbers (and modified) just to read the rest on a character base and the print it character by character into a new file so that i can avoid string array completly.

View 1 Replies View Related

C++ :: Sdl2 Copy And Paste Fallback Renderer

Jul 16, 2014

Well if you don't know, there are multiple renderers in sdl, and on some don't work on certain computers, so people use a fallback ex: "accelerated renderer -> software renderer". Sadly, I haven't came across an example that I could copy and paste.

View 16 Replies View Related

C# :: How To Make Copy And Paste Work With DataGridTemplateColumn

Feb 22, 2014

I have a WPF DataGrid with DataGridTemplateColumns, when I select rows and use Ctrl+C, and then in Excel or any document Ctrl+V, no data is pasted. If I change columns to DataGridTextColumn then copy and paste works fine. What can I do to make work copy & paste with DataGridTemplateColumn? Also when I set ClipboardContentBinding="{Binding FirstName}" for the template column, Null Refrence exception is thrown.

View 1 Replies View Related

C :: Write A Program To Copy One File To Another?

Feb 11, 2013

Here I was trying to write a program to copy one file to another.

Code:
#include <stdio.h>#include <stdlib.h>
int main(int argc, char *argv[])
{
FILE *fp , *ft;

[Code]....

So it should copy test1 to test2. Now I created test1 in gedit. I just put one character "c" in it and closed it. And I ran the program. When I check sizes of test1 and test2 , using

ls -l

command, I see that test2 has 4 bytes and test1 has 2 bytes. So something strange is happening here. I just put a single character in test1, so shouldn't it show 1 byte ? And why test2 is showing 4 bytes ? I have Win XP on my laptop. And I use Ubuntu 12 inside VirtualBox. So this is Linux environment...

View 10 Replies View Related

C++ :: How To Make Source Code Into Functional Program

Jun 10, 2013

How to make a source code into a functional program that a user can open and use without coming across the source code and building or running it.

View 1 Replies View Related

C++ :: Program Needs To Compile Various Source Files At Runtime

Oct 30, 2014

My program needs to compile various source files at runtime.What is the most elegant way to compile cross platform with g++ from within my program? Is there a gcc-library I can use? I know that I could use popen() to open a Unix pipe and call g++ as command line tool. But first it isn't really cross platform and second it doesn't seem elegant to me.

View 10 Replies View Related

C :: How To Share Variable Value From One Source File To Other Header File

Dec 11, 2014

I wanted to share the value of a variable from Sender Program to Receive after program and want to calculate difference between send and receive. After studying Header file concept I program following three.

Now I am struck. How to to compile? I link all these file. I used following method:

Code:
gcc Sender.c -o Sender Sender.h
gcc Receiver.c -o Receiver Student.h

Then I run Sender and after that Receiver.I per my knowledge, Receiver should give difference but it gives error :

Code:
Receiver.c: In function "main":
Receiver.c:10:42: error: "Send" undeclared (first use in this function)
printf(" Total Receive is %d
",Receive-Send);

Code:
Sender.c
#include <stdio.h>
int Send ;
void main(){

[Code] ....

View 2 Replies View Related

C++ :: Source File And Header File Are Not Compiled Together

Jan 30, 2013

My socket.cpp program got error. it showed "socket.h: no such file or directory". I had put my header file (socket.h) in the same place with my source file.

View 1 Replies View Related

Visual C++ :: Paste A SetClipboardData Image To Powerpoint?

Jan 21, 2014

I have a VisualC++ program to display image data to the screen. The data is a 24-bit, RGB bitmap that is properly shown using BitBlt().

I have a CopyWindow() function that puts the BITMAPINFO structure and RGB image data on the clipboard as a DIB with the SetClipboardData(CF_DIB,...) call.

My problem happens when I try to paste the image into MS Powerpoint (Office 2010). I've tried Paste and all the options in Paste Special but the image will not appear.

If I open Paint and do a Paste, the image appears properly in that application. Then I can do a Copy from there and am able to Paste that into Powerpoint.

How is Paint able to accept the DIB? And what is different about how Paste puts that bitmap onto the Clipboard so that Powerpoint can see it?

View 4 Replies View Related

C :: Declaration Of Array In Another Source File

May 5, 2014

I was going through a code where i found the definition of int array[63] in one of the source files. But i also found the declaration as extern int array[66] in another source file. This is clearly wrong, but my doubt is how the compiler compiled it. It should have thrown error. In case if it compiles then what will be the behavior of the system? Will it be normal or some undefined behavior?

View 3 Replies View Related

C++ :: Making Exe File From Source Code?

Sep 4, 2013

I use a programming language called layout which nobody here has probably ever heard of. It was discontinued over 15 years years ago but it was a very visual & easy to use piece of software - no coding required. In fact once you name all the variables on cards (forms) from then on it's just mouse clicking & occassionaly typing a number if required. It used blackboxes in a flowchart arrangement which were pre-done code for doing just about anything. i.e opening windows, handling numbers & text, files etc. I have written many programs with it including database management, quoting software & currently use it in my business to track my jobs & do invoicing & ordering. It's a pity it wasn't updated & still around today.

[URL]

Back to the problem. Being a 16 bit program it was written to run on Windows 3.1 but still works on Windows 7!! as long as it is the 32 bit version. I need to write a program that will run on 64 bit W7 without resorting to using a virtual PC solution. I have tried to find something similar that I might be able to use instead but so far nothing comes close to Layout. I just remembered today that layout can produce not only .exe programs but also various versions of C/C++ including visual c++. So I got this idea that if I could get those files I might be able to stick them into a C compiler program to re-make a "modern" exe file.

I could just do a simple sample program & send the source code to them to see if it works on a 64 bit version of Windows 7. how I can do this myself to produce a working exe file.

View 5 Replies View Related

C# :: How To Get Source Path Of Selected File

Jun 5, 2014

how to get source path of selected file.

for example :

selected image in E:/

E:ewfolderillustration.jpg

application - asp.net(C#)

View 4 Replies View Related

Visual C++ :: How To Use A Different File For The Source In The Debugger

Nov 3, 2013

Visual studio 2012

I have a project that has a few .asm files (assembly language code), I have the compiler/assembler set to create a list file for the assembly code and would like the debugger to use the .lst file for the source instead of the .asm files because in the .asm files the macros are not expanded like they are in the .lst files which makes debugging difficult sometimes.

View 1 Replies View Related

C :: Including Source File Twice But With Include Guard

Jun 14, 2014

I have four source files. The main source file includes two other source files. The two other source files both include the fourth source file. In the fourth source file I have an include guard. Will the code from the fourth source file exist in two locations in the compiled code? Is this something that is compiler dependent? An example of this is shown in the code below.

Code:

// filename: main.c
#include "source1.c"
#include "source2.c"

[Code]....

View 4 Replies View Related

C++ :: Including Header Files To Source File?

Jul 10, 2013

For example, I have the below files in a project called Calculate :

Source files : Calculate.cpp , Average.cpp (with out main)
Header files : Calculate.h , Average.h

I knew in general, we have to include Average.h to project header file Calculate.h to make it as part of project.

technical difference between adding header file (Average.h) to either project header file (Calculate.h) or project source file (Calculate.cpp) ?

I found no difference in an output. But, there must be technical difference.

View 3 Replies View Related

C :: How To Read Data In A File And Print It Then Copy Contents To A File

Mar 8, 2013

Code:

#include <stdio.h>
#include <stdlib.h>
int main (int argc, char *argv[])
{
char buffer[256];
FILE * myfile;
myfile = fopen("read.txt","r");

[Code]...

I also got an error in printing wherein the data in read.txt is "Hello" newline "World" and my program prints world twice.

View 3 Replies View Related

C++ :: Creating Another Source File In Console Application - VS Error

Jan 5, 2014

All I am trying to do is create another source file in a simple Visual Studio C++ console application.

I get the following errors:

intellisense: expected a delcaration
error C2447: "{" missing function header

I didn't create another int main () in this source file, so what is causing these errors.

View 1 Replies View Related

C :: Maintain List Of Variables Inside Source File

Apr 24, 2013

I'm about to begin work on an exercise that requires me to maintain a list of the variables inside a c source file. I'm trying to figure out how I'm going to pluck out the variable names from all the other noise. My first thought would be to count any word that isn't a keyword or other type of grammar syntax, such as parenthesis, brackets, semicolons, etc. right?

View 10 Replies View Related

C/C++ :: Placing Struct Of Object In Header And Source File?

Jul 19, 2014

Let's say I am using a library containing classes called class1 and class2 but both classes take three arguments to construct them. eg. class1(int a, int b, int c). and the same for class2

The below is an example of how to lay out the structure in the header and source file if class1 and class2 don't have any arguments in their constructor. But.... I'm not sure how to go about the below to take into account the constructor arguments of class1 and class2.

program.h
struct thestructure
{
thestructure(class1, class2); //constructor.

[Code].....

View 5 Replies View Related

C/C++ :: Compiling Source Code And Making Binary File

Apr 19, 2014

How to compile this source code and make a binary file

I think this need linux and run make command or gcc

This binary is a super user for android

source code attached

Attached File(s) : su.zip (7.59K)

View 3 Replies View Related

Visual C++ :: Game Controlled At Runtime By External Source File

Mar 24, 2013

Is it possible to create a program like Robocode, a game controlled at runtime by an external source file in visual c ++? For example create a checkers game where there would be an external source file, read at runtime, which would play automatically, with artificial intelligence. You can? If yes, how?

View 9 Replies View Related

C++ :: How To Copy TXT File

Nov 21, 2014

How to copy a .txt file

View 4 Replies View Related

C++ :: String Copy - Program To Reverse Word Order In Sentence

Apr 2, 2012

I am trying to write a program that takes a sentence and reverses the word order.

For instance This is a Bird would become Bird a is This

Code :

#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main (void) {
char input_buffer[1024];
char middle[1024];

[Code] ....

View 3 Replies View Related

C :: Copy Binary File To 2D Array?

Jun 12, 2013

Code:

#include<stdio.h>
void main() {
int x=0;
int y=0;
char c;
FILE* HUG;
FILE*fopen();

[Code] ....

View 10 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved