Hi all, I am learning C++/CLI and stuck with a problem.
I have a header file that looks like
typedef struct _DATA_INFO {
WORD ONE
WORD TWO
WORD THREE
} DATA_INFO
public ref class ManagedDataInfo
{
DATA_INFO* info;
public ManagedDataInfo()
{
info=new DATA_INFO();
}
...
A long time ago I used to program in C for school. I remember something that I really hated about C: unassigned pointers do not point to NULL.
I asked many people including teachers why in the world would they make the default behavior of an unassigned pointer not point to NULL as it seems far more dangerous for it to be unpredictable.
...
I have a char* name which is a string representation of the short I want, such as "15" and need to output this as unsigned short unitId to a binary file. This cast must also be cross-platform compatible.
Is this the correct cast: unitId = unsigned short(temp);
Please note that I am at an beginner level in understanding binary.
...
I want to copy and paste a C function I found in another program into my C++ program.
One of the function arguments uses the "this" pointer.
void cfunction( FILE *outfilefd, const VARTYPEDEFINED this);
The C++ compiler errors here on the function prototype:
error C2143: syntax error : missing ')' before 'this'
How do I make this...
I know Python doesn't have pointers, but is there a way to have this yield 2 instead
>>> a = 1
>>> b = a # modify this line somehow so that b "points to" a
>>> a = 2
>>> b
1
?
Here's an example: I want form.data['field'] and form.field.value to always have the same value. It's not completely necessary, but I think it would be nice....
Hi,
Basically in the code below, my final array does not seem to have the contents from function1(). Any ideas on why I can't get this to work ? Thanks.
#include <stdio.h>
#include <string.h>
#include<stdlib.h>
unsigned char *function1()
{
unsigned char array2[] = { 0x4a,0xb2 };
return (array2 );
}
main()
...
Greetings all,
Please take a look at following code:
#include <stdio.h>
#include <iostream>
using namespace std;
typedef struct MyType{
int num1;
};
void test(MyType **src)
{
MyType *ret=new MyType;
ret->num1=666;
*src=ret;
}
int main(){
MyType *mSrc;
test(&mSrc);
printf("%d Address\n",mSrc);
printf("%d Value \n",mSrc->num1)...
It gives the error in the title about this piece of code:
string DDateTime::date2OracleDate(DATE Date)
{
string s;
s="TO_DATE('" + DateFormat("%d/%m/%Y",Date) + "','dd/MM/YYYY')";
return s;
}
I don't understand how that is possible, no pointers involved....
EDIT:
string DDateTime::DateFormat(string sFormat,DATE Date)
{
...
Hei community,
I've got a small question concerning the deletion of pointers.
I am working with pointer-to-pointer matrices of Dimension 1024x1024. Since I am creating them dynamically, I delete the allocated space for them at the end of the program. But doing this in the usual loop costs quite a lot of time - I measured about 2sec usi...
Somebody write this function
void strToUpper(char *p) {
while (*p) {
*p = TOUPPER(*p);
*p++; //<-- Line to pay attention
}
}
I asked, why do you put the * before p++?
answer: because "It's the same", I corrected the code and then stay angry for a while, because both really work the same...
void strToUpper...
What's wrong with this:
wchar_t * t = new wchar_t;
t = "Tony";
I thought I could use a wchar_t pointer as a string...
...
I'm an intermittent programmer and seem to have forgotten a lot of basics recently.
I've created a class SimPars to hold several two-dimensional arrays; the one shown below is demPMFs. I'm going to pass a pointer to an instance of SimPars to other classes, and I want these classes to be able to read the arrays using SimPars accessor fun...
I define this structure:
struct s_molecule
{
std::string res_name;
std::vector<t_particle> my_particles;
std::vector<t_bond> my_bonds;
std::vector<t_angle> my_angles;
std::vector<t_dihedral> my_dihedrals;
s_molecule& operator=(const s_molecule &to_assign)
{
res_name = to_assign.res_name;
my_particles = to_assign.m...
I've been getting more and more involved in C / C++ programming lately and have noticed a trend in the way people name datatypes in their code.
I always see prefixes such as p, m, ui, etc.
For example: mPlayerNames, pData, uiNumResets
I think I get it, but just to confirm: Do these prefixes indicate the data type? ie:
mData -> Matrix ...
I am pretty sure this has something to do with a vector of void function pointers, but I can't really make anything out of it.
Can someone break this down for me?
__gnu_cxx::__normal_iterator<unsigned long long const*, std::vector<unsigned long long, std::allocator<unsigned long long> > >::difference_type __gnu_cxx::operator-<unsigned ...
Hello,
I try to call
g_io_scheduler_push_job(job_func, ¶m, NULL, G_PRIORITY_HIGH, generator_cancellable);
In my C/gtk+ application for runing job_func in another thread then main program. But have segfault when i call this function, and debugger sad that: ** userdata attempt to difference a generic pointer**
My job_func:
gbool...
Hey
I am parsing a binary file using a specification. The file comes in big-endian mode because it has streamed packets accumulated. I have to reverse the length of the packets in order to "reinterpret_cast" them into the right variable type. (I am not able to use net/inet.h function because the packets has different lengths).
The read...
Related to: http://stackoverflow.com/questions/2625719/c-private-pointer-leaking
According to Effective C++ (Item 28), "avoid returning handles (references, pointers, or iterators) to object internals. It increases encapsulation, helps const member functions act const, and minimizes the creation of dangling handles."
Returning objects ...
Possible Duplicate:
When you exit a C application, is the malloc-ed memory automatically freed?
In C, is it necessary to free a pointer at exit?
When the program exists, does it free memory from pointers still pointing to an allocated block?
Is it dependent on the OS?
...
We're getting some funny behavior in the Visual Studio debugger with the following.
I'm not sure if it's the code or some debugger weirdness (seen stuff like it before).
We are trying to return a pointer to an value in an array.
The weird behavior is that the value of x changes to equal y after func() is called a second time...at least,...