LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-04-2005, 04:01 PM   #1
igor@44
Member
 
Registered: Jun 2005
Distribution: Slackware 10.2
Posts: 32

Rep: Reputation: 15
Unhappy What's wrong ?


I'm writting C++ program, I have KANOTIX, g++ . When I try to compile
Code:
main() 
{
CopyFile("~/Desktop/what.txt, "~/Dekstop/what3.txt", false);
}
g++ "says" to me :

Quote:
cooldude.c: In function `int main()':
copy.c:3: error: `Dekstop' undeclared (first use this function)
copy.c:3: error: (Each undeclared identifier is reported only once for each
function it appears in.)
copy.c:3: error: `what3' undeclared (first use this function)
copy.c:3:49: missing terminating " character
copy.c:4: error: parse error before string constant
Can somebody "translate" this to me? What should I do?
 
Old 08-04-2005, 04:11 PM   #2
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
  • You are missing a closing quote for your first parameter
  • Are you sure you want to copy from the Desktop folder to Dekstop? Looks like a typo there
  • Because the ~ expansion is a bash thing, i don't think your C program is going to expand that to /home/username for you. You may need to supply a full path.
  • Edit: It also appears you are trying to use the Win32 CopyFile function. That's not in the standard C/C++ library. Since you are using Linux, it's not even in one of the typical Linux libraries. You can however, probably install the Wine libraries and use those. (Although, if the only Win32 function you want to use is CopyFile, there are probably better ways to do it than using Winelib just for that...)

Last edited by deiussum; 08-04-2005 at 06:16 PM.
 
Old 08-04-2005, 04:11 PM   #3
lowpro2k3
Member
 
Registered: Oct 2003
Location: Canada
Distribution: Slackware
Posts: 340

Rep: Reputation: 30
Your missing a closing quotation for the first argument to 'CopyFile'.
 
Old 08-05-2005, 04:58 AM   #4
igor@44
Member
 
Registered: Jun 2005
Distribution: Slackware 10.2
Posts: 32

Original Poster
Rep: Reputation: 15
Quote:
It also appears you are trying to use the Win32 CopyFile function. That's not in the standard C/C++ library. Since you are using Linux, it's not even in one of the typical Linux libraries. You can however, probably install the Wine libraries and use those. (Although, if the only Win32 function you want to use is CopyFile, there are probably better ways to do it than using Winelib just for that...)
Is there any other way to copy file in linux ?
 
Old 08-05-2005, 05:31 AM   #5
kjordan
Member
 
Registered: Jul 2004
Distribution: LFS, I felt the itch and scratched it
Posts: 227

Rep: Reputation: 31
The cp command is the easiest way to copy a file.

If you want to copy a file through a C program, you could either do it manually by opening it up, reading, and then writing it out to another file or use the system function:
system("cp ~/Desktop/what.txt ~/Dekstop/what3.txt");
 
Old 08-05-2005, 03:51 PM   #6
igor@44
Member
 
Registered: Jun 2005
Distribution: Slackware 10.2
Posts: 32

Original Poster
Rep: Reputation: 15
I wanted to make file that can copy itself into ~/.kde/Autostart . How can I do that?
 
Old 08-07-2005, 04:45 AM   #7
eddiebaby1023
Member
 
Registered: May 2005
Posts: 378

Rep: Reputation: 33
Quote:
Originally posted by igor@44
Is there any other way to copy file in linux ?
Many ways.
Code:
cp filea fileb
cat filea >fileb
cat <filea >fileb
sed '' filea >fileb
dd if=filea of=fileb
echo "$(<filea)" >fileb
awk '{print}' filea >fileb
awk '//' filea >fileb
cp is the most obvious, though.
 
Old 08-07-2005, 04:50 AM   #8
eddiebaby1023
Member
 
Registered: May 2005
Posts: 378

Rep: Reputation: 33
Quote:
Originally posted by igor@44
I wanted to make file that can copy itself into ~/.kde/Autostart . How can I do that?
Well, if you really want a file to copy itself (you still have to execute it, though):
Code:
#!/bin/more +2 ~/.kde/Autostart
Put the wanted
file contents in the rest of the
file, make it executable with
chmod a+x thisfile'sname
and then execute it
will copy all but the first line into ~/.kde/Autostart. I'm not sure this is really what you mean, though, is it?
 
Old 08-10-2005, 04:36 AM   #9
igor@44
Member
 
Registered: Jun 2005
Distribution: Slackware 10.2
Posts: 32

Original Poster
Rep: Reputation: 15
Yeah, that is what I really mean but how to do it? gimme code
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
what' s wrong phoenix_fei Programming 4 01-18-2005 10:56 AM
my time is wrong and calender is also wrong Paxmaster Linux - General 6 12-16-2004 12:46 AM
What's wrong? whaase Linux - Software 7 10-20-2003 12:39 AM
What am I doing wrong? funkenbooty Linux - Newbie 14 07-26-2003 02:16 AM
What did I do wrong? yakko Linux - Newbie 7 05-02-2002 07:09 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration