LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-10-2003, 08:49 PM   #1
liguorir
Member
 
Registered: May 2003
Posts: 256

Rep: Reputation: 30
Talking C++/C Counterparts.


What are C++ counterparts for the following in C :

arrays
printf
malloc
free
strcpy
strncpy
memcpy
memmove
qsort

Thanks,

Robert Liguori
 
Old 07-11-2003, 12:06 PM   #2
lyle_s
Member
 
Registered: Jul 2003
Distribution: Slackware
Posts: 389

Rep: Reputation: 52
Re: C++/C Counterparts.

C: C++ counterpart

arrays: std::vector, or use arrays the same as in C. There are many more containers in the STL.

printf : std::cout

malloc: new
free: delete

strcpy: = (assignment), or one of std::string's constructors.
strncpy: with std::string, you don't need to worry about string length (or the null terminator) anymore.
memcpy: don't know
memmove: don't know
You can still use null-terminated arrays of char like in C (a.k.a. C-strings) in C++ if you really wanted these functions (#include <cstring>).

qsort: std::sort, or a sort member function for the particular container you're using.

Lyle
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Linux Counterparts Eyaw_Nayr Linux - Software 1 08-15-2004 07:09 PM


All times are GMT -5. The time now is 10:03 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration