|
Hm... Try it :
node a(3); a.next = new node(4); a.next->next = new node(5); a.next = move(a.next->next); unique_ptr<node> temp = move(a.next->next);
a.next = move(temp);
PS: any pre 0x11 C++ strcture or class may have a destructor as well :
struct node {
int m_iData;
node* m_pNext;
node(int iData) : m_iData(iData), m_pNext(NULL) {}
~node() { delete m_pNext; }
node* detach() { node* prevNext(m_pNext); m_pNext = NULL; return prevNext; }
} a(3);
They sought it with thimbles, they sought it with care;
They pursued it with forks and hope;
They threatened its life with a railway-share;
They charmed it with smiles and soap.
modified 19-Nov-12 17:07pm.
|
|
|
|
|
I'm just guessing but the statement
a.next = b; looks like it should generate some kind of type mismatch error. At the very least I think you would have to deliberately cast 'b' to something before you can assign it to a unique_ptr variable. I'm not sure about the other two errors.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
write a XOR using the c programming language.
This program must accept as input from the user a value between 0 and 255 to be used as the
secret key, the name of the input file and the name of the output file. No line in the input file
should contain more than 4096 characters.
After the user would have provided their secret key, this program should read and perform an
XOR cipher on the contents of the input file and write the result to the output file.
If the input file has already been encrypted and the identical secret key that was used to
perform the initial encryption is provided, then the contents of the output file should be
deciphered into its original plain text.
can you please provide me with the algorithm on how to go about doing this work.
|
|
|
|
|
This is a fairly obvious homework question so you should at least make an effort to do the work yourself. If you do not understand how to apply XOR to a string of characters then you should read this page[^]. Similarly, reading and writing files is a basic part of the language that can be learned by reading these pages[^].
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
thandy mitchell wrote: can you please provide me with the algorithm on how to go about doing this work
The algorithm is already provided by your requirements.
Veni, vidi, vici.
|
|
|
|
|
hi,
i want to know how to access some part of data in excel sheet and copy to text file using pure c++.....please send me a code if u know this.....
|
|
|
|
|
I have code that do that, but is in MFC, is good for you ?
|
|
|
|
|
Here at CodeProject we have an article on such topic: "Accessing Excel Spreadsheets via C++"[^]. It uses ATL and COM , I don't know if you include those libraries into the 'pure C++ world'.
Veni, vidi, vici.
|
|
|
|
|
You may use different methods to read Excel files. Which one to use depends on the version of the Excel files (XLS and/or XLSX) and if Excel is installed or not:
- Using
Excel Automation (COM / OLE Dispatch) with the Excel type library. This requires an installed Excel on the machine running your application (which defines what Excel file versions can be read) and the Excel type library on the development machine. - Using
ODBC or ADO (OLE DB ). These are database interfaces that handle sheets from Excel files like databases tables. Drivers for XLS files are present on all Windows systems. Drivers for XLSX files are installed by Office 2007 or with the 'Microsoft Access Database Engine 2010 Redistributable' package. - Using a library. Examples are the ExcelFormat Library[^] here at CodeProject and the commercial LibXL[^] library.
Once you have decided which method you want to use, search for samples here at CP and in the web using the above keywords. But be prepared that reading Excel files is not done with a few lines of codes.
|
|
|
|
|
Dear coders, for few days, I struggle to solve a simple problem: to scroll the window after zooming, in such a way, that mouse position stay in the exactly same logical position ... and I didn't succeded.
The view is based on CScrollView, mapping mode is always MM_TEXT, zomming is changing by 10%. Nothing special.
Have you see how Window Photo Viewer (from Windows 7) work on zooming ? I want to implement the same behaviour ... does anybody do that before ? Anybody have similar code ?
modified 19-Nov-12 4:19am.
|
|
|
|
|
|
Is it possible to write precommit hooks for svn in c/c++?
If so how to write a hook which will ask the user to update document version everytime the user checks in the document in svn. My knowledge is limited to the fact that the .exe to be created should be named Precommit and be placed in the repository where the user performs any action in repository.Please guide me.
|
|
|
|
|
SVN will automatically update the version when the document is checked in. It also provides a user API that you can interface with. See here[^] for further information.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Hello Mukul,
I found this online source to be quite illuminating. Take a look at it. Hopefull you willl find it both helpful and beneficial.
"http://stackoverflow.com/questions/9773678/how-to-write-a-svn-hook-script"
Best of Luck,
Happy Reading,
With Kinds Regards,
April
Comm100 - Leading Live Chat Software Provider
modified 27-May-14 8:38am.
|
|
|
|
|
I didn't find any useful code online for implementing the RealTime scheduler in c++. is there anyone can help provide ? Thanks advance!
|
|
|
|
|
|
Hi All,
Can you please tell me, what all the things i need to take care when i am trying to port my device driver 32 bit to windows 7 64 bit?
|
|
|
|
|
Googling with following phases seems to turn up results.
how to convert from 32bit to 64bit windows 7
gotchas converting from 32bit to 64bit windows 7
tutorial converting from 32bit to 64bit windows 7
converting 32bit to 64bit windows 7 site:codeproject.com
Last of those turned up the following (could be more.)
Lessons on development of 64-bit C/C++ applications[^]
|
|
|
|
|
...except this is a driver, not an app...
|
|
|
|
|
|
Thanks for the reply.
In our case we have a different types of data types used in the app(ie UINT8,UINT16,UINT32) and the different types of pointers(ie PUINT8,PUINT16,PUINT32).Here do i need to change the types to 64 or not?Because i am getting the crashes in the driver driver in different places.
|
|
|
|
|
Yea. You must.
Be careful when performing unsigned and signed operations. Consider the following:
ULONG x;
LONG y;
LONG *pVar1;
LONG *pVar2;
pVar2 = pVar1 + y * (x - 1);
The problem arises because x is unsigned, which makes the entire expression unsigned. This works fine unless y is negative.
In this case, y is converted to an unsigned value, the expression is evaluated using 32-bit precision, scaled, and added to pVar1.
On 64-bit Windows, this 32-bit unsigned negative number becomes a large 64-bit positive number, which gives the wrong result.
To fix this problem, declare x as a signed value or explicitly typecast it to LONG in the expression.
|
|
|
|
|
Thanks for the reply,
in case of pointers for eg PUINT8 OR PUINT16 do i need to change the datatypes to PUINT32 or PUINT64?
and for normal variables UINT8 OR UINT16 do i need to change the datatypes to UINT32 or UINT64?
if not in which cases i have to change the data types.
I am totally new to the drivers programming,Please suggest me some links.
|
|
|
|
|
|
Use size_t types pretty much every where.
|
|
|
|