Visual C++ :: Can't Initialize Struct With CString

Apr 7, 2013

I'm trying to compile the following and it doesn't work? How can I get the CString to initialize.

Code:

struct print {
int x; //row
int y; //col
int fid;
CString *data;
char *format;

[Code] .....

the char *format is not a problem, but compiler doesn't like CString *data;

tried CSting data and that also doesn't work, typecasting didn't work either?

View 14 Replies


ADVERTISEMENT

C :: Initialize Data Member In Struct

Mar 28, 2013

I was looking at some linked list material and was wondering something. Can you initialize a data member inside a struct like in C++? i.e.

Code:
typedef struct node
{
int data;
struct node * next = NULL; // this is the line in question
} LLnode;

View 3 Replies View Related

C++ :: Initialize Char Pointer Array In Struct

Nov 28, 2014

I am trying to store data in a struct to be able to read it latter . have problems initializing this.

struct FoodAndDrink {
struct Food {
char* CannedGoods[2] = {
"Canned Spaghetti",
"Canned Tuna",

[code] .....

View 7 Replies View Related

Visual C++ :: First Chance Exception CString

Jul 9, 2014

Why would the following line of code cause an exception and how can I fix it? This is with Visual Studio 2013 and it is set to use "Multibyte Character Set". This is a very old program that I was updating.

Code: thepath = dadir + "*.csv";

Both dadir and thepath are type CString.

Prior to this line dadir looks fine when I look at it in the debugger but when I reach this line of code I get

First-chance exception at 0x0FA08EE1 (mfc120d.dll) in GAQUtilities2014.exe: 0xC0000005: Access violation reading location 0xFEFEFFC6.

View 5 Replies View Related

Visual C++ :: Array Of CString Size Checking

Apr 4, 2014

Code:
//Class header
CString m_cstrArry[5];

Code:
//Class source
void Ctry4Dlg::OnInitDialog() {
m_cstrArry[0] = _T("TEXT 0 |");
m_cstrArry[1] = _T("TEXT 1 |");
m_cstrArry[2] = _T("TEXT 2 |");

[Code] .....

View 8 Replies View Related

Visual C++ :: CString Class In Non-MFC Static Library

Sep 13, 2013

I have a non-MFC static library which I share between a number of different projects, some non-MFC and some MFC. Currently the static library uses a typedef of std::wstring and std::string for UNICODE and non-UNICODE builds.

After discovering it's possible to use CString in non-MFC applications, by including atlstr.h header, I decided I'd rather that than using stl strings and having to keep converting between the different types. However, I seem to be struggling with linker errors when linking the library with a MFC application.

Can I create a non-MFC static library using CString from atlstr.h and link it with a MFC application?

View 11 Replies View Related

Visual C++ :: Detecting Garbage Chars In CString

Feb 1, 2013

How do I detect garbage chars in a CString. Actually I'm reading some data from COM port. In some certain condition it will give some garbage as a version no. Now I need to show _T("N/A") in case of there is any garbage.

My solution is to check for a Valid char or integer. If found its correct else Garbage.

View 11 Replies View Related

Visual C++ :: Converting ASCII To CString Not Working In 6.0?

Sep 22, 2012

The below code is working fine in VS2008 and not working in VC6.0 (taking garbage values) this code is for converting hex values to string.

sending Input string is : 727332333263 required output: rs232c

DWORD AsciiToString(LPCTSTR f_chInputChar, LPTSTR f_chOutputChar) {
long ch;
int i,j;
TCHAR tmp[2];
int len = _tcslen(f_chInputChar);

[Code] ....

View 5 Replies View Related

Visual C++ :: CString - Display Some Data In Text Format On A Dialog

Aug 7, 2014

I am trying to display some data in text format on a dialog and I am using a CString to do it. Below is how I coded it.

Code:
CString outputStr;
CString auxStr;
// Add header
outputStr.Format("");
auxStr.Format("%-7s%-20s%-7s%-20s%s

[Code] .....

But the output rows are not aligned as shown in the attached picture. There a two problems.

1. Data rows don't align with the header row.
2. When the first element of a row changes to two digits, the other elements are shifted.

According to MSDN [URL] ...., CString::Format() works the same way as printf(). I wrote a small program using printf() to do the same thing, and the output in the console are perfectly aligned.

What have I missed when doing the display in GUI?

View 14 Replies View Related

Visual C++ :: Initialize Constructor In Array Of Objects?

Oct 28, 2012

What the best way to initialize a constructor in an array of objects?

Usually I declare an array of objects like so:

Code:
Car toyota[100];

Is this the only way I know to initialize a constructor of an array:

Code:
for (int i = 0; i < 100; i++)
{
toyota[i] = Car(x, y);
}

Is this the proper way?

View 1 Replies View Related

Visual C++ :: Resource Editor Failed To Initialize ActiveX

Feb 27, 2014

I'm working on a project which consists of several ocx loaded by one exe. The platform is WinCE. Now I'm on a process to create a new ocx. I do have a copy of those ocx projects in Win32 platform. These Win32 versions were only used to register ocx in local system and then put those on to application dialog by 'Insert ActiveX'.

Now the problem is those Win32 projects are so outdated, and unable to build. Getting too many linking errors to be solved.

I have build the new ocx and link that with exe manually by editing .rc file and all. But still no luck. New ocx is getting registered in WinCE device but failing to start application.

View 6 Replies View Related

C++ :: Converting CString To Int?

May 16, 2013

I am having problems with converting a CString to an int and than doing checks on the int to see if it is in a particualr range.Below is what I am doing.

CString numstr = "28"
int num = atoi(numstr);
BOOL valid = TRUE;
if(num < -32,768 {
valid = FALSE;
}

For some reason when running the above code the if statement is executed but it should not be becasue 28 is not less than -32,768. Why this is happening, I am not seeing the reason for this at all!! The num variable is being assigned the correct value.

View 5 Replies View Related

Visual C++ :: Exporting Struct From DLL

Nov 8, 2013

I'm trying to build the gtkmm library using MSVC. One of its source files declares a struct called BuiltinStockID together with some objects of that type - e.g.

Code:
// In the header file:-
namespace Gtk {
struct BuiltinStockID {
const char* id;

[Code] ....

GTKMM_API is obviously _declspec(dllimport) (or export) as appropriate. It seems a bit unusual to use extern in addition GTKMM_API but the code won't compile if I try to exclude it. The actual instantiations are in one of the library's source files- e.g.

Code:
// In a source file
const Gtk::BuiltinStockID APPLY = { GTK_STOCK_APPLY };
const Gtk::BuiltinStockID CANCEL = { GTK_STOCK_CANCEL };
const Gtk::BuiltinStockID OK = { GTK_STOCK_OK };

GTK_STOCK_APPLY etc are simple strings such as "gtk-apply". They mostly refer to image files for the library to load (in this case, for dialog button images) although that's probably not relevant to the problem.

If I run dumpbin /EXPORTS on the built DLL it does seem to have some exported symbols with the names Gtk::Stock::APPLY, Gtk::Stock::CANCEL, Gtk::Stock::OK etc. However, if I write this in one of my own source files:-

Code:
Gtk::BuiltinStockID MyStockID;
MyStockID = Gtk::Stock::CANCEL; // <--- debugger reports <Bad Ptr>
You can see that the Gtk::Stock::CANCEL object is invalid (my debugger reports it as a bad pointer). Likewise, if I try to pass Gtk::Stock::CANCEL as a parameter to a function.

View 13 Replies View Related

C++ :: How To Convert A Char To CString

Aug 27, 2013

I am trying to convert a char to a CString, I have tried to use the CString.Format method but didn't work. I have a char(char holder[10]) and I want to see if holder is a certain string, say for instance SeaLevel. Below is the code that I also tried.

if(holder == "SeaLevel")
{
//do something
}

View 3 Replies View Related

C++ :: Circular Right Shift A Cstring

Jan 29, 2013

I need to circular right shift a cstring in C++

Let's say I have unsigned char test[10] = "HELLO!!!"; How would I go about circularly shifting this to the right? Inline assembly instructions would be ok too

View 6 Replies View Related

C++ :: Point Of NULL In CString

Jul 9, 2014

I dont see any point of NULL in cstring. The code given below just outputs same as it would have done with NULL. My understanding is if size of char array is less than length of char array then null must be manually added?

#include <iostream>
using namespace std;
int main(){
char chr[0];
cin>>chr;//or if you use cin.getline;
cout<<chr<<endl;
return 0;
}

Enter something: hellowwwww
hellowwwww
Segmentation fault (core dumped)

why? for NULL char or something else?

View 1 Replies View Related

C/C++ :: Converting Key Combination To CString?

Jul 24, 2012

ShAltGr+A represents a foreign character in a font set.

How to make a CString variable for this so it can be displayed in a text editor programmatically?

Typing the combination of course works.

View 1 Replies View Related

Visual C++ :: Reading COM Struct From IDispatch

Apr 1, 2014

My question is that I have C++ function which has a IDispatch input as argument.

I am trying to read the struct from IDispatch.

So basically, the struct definition is

struct MyStruct {
void *m_pValue;
};

I can get the ITypeInfo and read the whole structure definition from it. But I do not know how to read the struct instance value. I am dumping all the info from ITypeInfo

TYPEATTR
========
guid {A1CB710C-8D50-3181-BB38-65CE2E98F9A6} _GUID
lcid 0x00000000 unsigned long
dwReserved 0x00000000 unsigned long
memidConstructor 0xffffffff long
memidDestructor 0xffffffff long

[Code] ....

View 6 Replies View Related

Visual C++ :: Returning Struct From Function

Oct 24, 2013

In my Header file:

class MyData {
struct Fparams {
int i;
bool flag;
};
}

Now in CPP file:

void MyData::GetData() {
Fparams fParam;
fparam = AllData();

[Code] ....

Now i get an error saying - error: no match for 'operator=' in fparam = AllData(); ........

View 10 Replies View Related

Visual C++ :: One Header File Defines A Struct And Other Uses It

Sep 19, 2012

Code:

// mesh.h
struct D3DXMESHCONTAINER_DERIVED
{
};

// allocmeshhierarchy.h
#include "mesh.h"
void GenerateSkinnedMesh (LPDIRECT3DDEVICE9 pDevice, D3DXMESHCONTAINER_DERIVED* pMeshContainer);

Error C2011: D3DXFRAME_DERIVED repeated definition of d: users documents visual studio 2010 projects perfectsim v5.0 perfectsim v5.0 mesh mesh.h the 11 1 PerfectSim V5.0

What is correct linkage method?

View 5 Replies View Related

Visual C++ :: How To Pass A Struct To A Dialog (WinAPI)

Feb 28, 2013

I want to pass some parameters to a dialog. I am trying to pass a struct as LPARAM in CreateDialogParam. How to access this structure from ONOK for example?

Code:
struct DlgParam{
std::wstring IEDllPath;
CString folderName;
};

[Code] .....

View 7 Replies View Related

Visual C++ :: Converting Program From Struct To Class

Sep 20, 2014

I am not exactly sure how to do this and i keep running into problems. This is my code here that works.

Code:
#include<iostream>
using namespace std;
struct record {
double quiz1;
double quiz2;
double midyear, midyear_one;

[Code] .....

View 5 Replies View Related

C/C++ :: Atoi Does Not Work / Converting Cstring Vector Into Ints

Feb 18, 2015

I have saved the contents of an int vector to a txt file and the numerical data was converted into a c-string. Nov I need to import and read the contents back into my program but I have not been able to convert c-string numerical data back into ints.

View 1 Replies View Related

C++ :: CString Program - Function Should Accept String Object Arguments

Feb 23, 2015

Write a function named replaceSubstring. The function should accept three C-string or string object arguments.

Let's call them string1, string2, and string3. It should search string1 for all occurrences of string2. When it finds an occurrence of string2, it should replace it with string3.

For example, suppose the three arguments have the following values:

string1: "the dog jumped over the fence"
string2: "the"
string3: "that"

With these three arguments, the function would return a string object with the value "that dog jumped over that fence." Demonstrate the function in a complete program.

View 1 Replies View Related

Visual C++ :: Operator Overload Not Defined Error When Type Accessed Through Const Struct

Oct 17, 2012

I have a basic vector/point class where I've overloaded a bunch of arithmetical operators:

Code:
#pragma once
class point {
public:
point() {
}
point(float p_x, float p_y, float p_z) : x(p_x), y(p_y), z(p_z)

[Code] ...

I can use it fine like

Code:
point p(50,50,50);
point q(50,50,50);
point t = p * q + q;

However when I put this point type into a struct and try to access the members after passing it through by const reference:

Code:
struct sextic {
point a,b,c,d,e,f,g;
};
inline static sextic sexticDifference(const sextic &p_sextic1, c

[Code] ....

This gives me an "operator not defined" error for compilation.

View 2 Replies View Related

C/C++ :: Sizeof (struct) Returns 6 More Bytes Than Actual Struct Size?

Sep 14, 2014

#include <stdio.h>
#define MAX_USERS 20
struct {
char ID[10];
char Name[40];
int Pos;

[Code] .....

I was attempting something weired with address to move data around when I discovered that the size of the array is not what I expected. I am passing this structure as &Users to a function that declares it as a void *, then I can deal with chunks of data (memmove) and not have to worry about index or things like that. However...sizeof is returning something I do not understand.

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved