How to manipulate CString's content [closed] - c++

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
guys, I have a problem, please help me!
I have a CString variable which will receieve from Database,and the data may like this:(8)(9)(10)(11) or more.
Now I want to change every number in CString,for example, add 1,the outcome should like this:
CString Data; the contest of CString data variable should be changed.
Before: (8)(9)(10)(11)
After: (9)(10)(11)(12)
I've tried Data.GetAt(i),but it returns a const pointer and I can't change it.
I konw maybe Data.GetBuffer() can get a pointer to manipulate CString,but I don't know how to do it.
So please help me ! Thanks a lot!

Don't change in-place. Specifically in your example, when you change (9) to (10) it needs 1 extra character of buffer space. Extract all the values somehow (a std::list of int perhaps), add whatever numbers you need, and then re-assemble into a string, and write it back all at once.

Related

Visual C++ member variables changing unexpectedly and unexplainably [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I'm initializing an instance of PhysWorld class as shown here:
At this point the member variables are as follows:
This seems correct to me.
Then this line executes:
We step into:
And at this point, the member variables look like:
Can someone please help me understand what is going on here? This is one of my first attempts in c++ so I'm guessing it's something stupid on my part.
Thanks!
You probably loose variable value on assignment:
pw = PhysWorld(...);
This statement constructs a temporary object, and then makes a call: pw.operator=(const PhysWorld&);. Check how you implement it (if you do).
Also your function setRectDef contains a serious bug: you are storing a pointer to a stack variable, which would be invalid after leaving the function scope, and accessing it later most likely ruin your stack.
Edit: how to handle tmpS.
You need to allocate your structure on heap:
b2PolygoinShapre *tmpS = new b2PolygoinShape;
tmpS->SetAsTextBox(...);
this->rect = tmpS;

Family tree structure in c++ [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to make a program that gets the information of a family including their names, SSN etc. I'm facing with two problems, firstly, what is the best data structure for this purpose,secondly, how should i get the information from the user, i mean when I'm getting info of father,i should determine his children, here is the problem.
how to connect his children to himself?
If it were me, I'd create a few different parallel arrays.
You're going to need to find out the algorithms for search through the arrays.
You're going to need to find out how to match them up together using the same index once the search finds a match. The index will probably be needed to be returned by reference to make things easier.
How to connect the children to the father maybe harder...
I don't know much about Binary Trees, we never talked about those in class. But that maybe the answer you're looking for. Sorry I couldn't be of more help. It's Christmas and it's 3AM lol. Good luck.

I wish to know how a function signature is validated [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I currently believe it is the compiler or the return type that does this but I'm not sure I just need a clarification
A function signature is matched first by it's name, then by it's arguments. Never by it's return type. For example if you have two methods called Add one taking two int values and returning a int and one taking two string values and returning a string, and you called it passing ints it wouldn't matter what you were setting it to the int version would be called.
Where this can get you in a bit of trouble is when you try method overloading with different numeric values. the compiler will try and help you (if you call a method expecting ints but pass a short it will try and figure out what you are trying to do).

Reading Image from memory, knowing pointer to memory. VC++ [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I've a camera that comes with an c++ api and SDK.
There is an callback Function that returns a
C++ pointer to the starting point of some RAW Image data stored in Memory
I want to
1) Get the Image
2) convert it to some image format
3) save it to hard disk
pointer is char*
How can I do it in VC++.
Thanks.
EDIT:
reposted question here:
https://stackoverflow.com/questions/10826313/reading-image-from-memory-and-painting-it-in-a-vc-mfc-application
Investigate OpenCV to convert the image to some format and then save it on the disk.
You might want to take a look at this post as well.

Haskell function which takes a list and return tuples [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
I have ordederd to make a function, which takes a list ex [3,4,6,1,29] and returns a list of tuples [(3,4),(4,6),(6,1),(1,29)]
This is a very easy question, it's really hard to help without defeating the purpose...
If you are allowed to use predifined functions, there is already one which can do almost all work for you (if you don't know which one, try finding it with http://www.haskell.org/hoogle/ ). Take a step back and think about the easier question how to produce a list [(3,3),(4,4),(6,6),(1,1),(29,29)].
If you can't use predefined functions, then recursion is your friend: What do you need to do for an empty list? What for a list with one element? With two elements?
Without any own effort I can't give more hints. If you're stuck, extend your question and show what you already got, and we'll try to help.