Typecasting goes the wrong way


Hi everybody, I'm trying to build an test-app to check out typecasting. I want to typecast from a bunch of u_chars (unsigned chars) to an structure i created. Here's the code: //////////////////////////////////////////////////////////////////////////////////// #include using namespace std; typedef unsigned char ...
Posted On: Monday 26th of November 2012 12:10:13 AM Total Views:  122
View Complete with Replies

RELATED TOPICS OF C Language PROGRAMMING LANGUAGE




Declaring a void variable and typecasting it later

, I was wondering if its possible to do something like this in c: Code: void variable = 'c'; if (xyz) { char variable2 = variable; } if (not xyz) { int variable3 = variable; } I tried it and gcc warned me, while stating that it was enabled by default, so I am not sure.
VIEWS ON THIS POST

308

Posted on:

Saturday 6th October 2012
View Replies!

regarding typecasting

I am new to c++ programming language. I have written small program , where i pass the char string then , i find out length. find_len( char *str); is the proto type for the function. I did type casting to give new name to char , typedef signed char sint; Then i replaced the function call with find_len(sint *str); when i compiled, i am getting the error saying, invalid conversion from `sint*' to `char*' i am not able to understand, what was the problem. Please help me out in knowing, why this problem is happening. Appreciate your help in this regard.
VIEWS ON THIS POST

330

Posted on:

Saturday 3rd November 2012
View Replies!

So how do you know which lib goes with a header file (dumb question I know)

>From other posts I have made I have made I have been told the only way to know what is in which header files is to look and as you learn the headers you will know what is available. Even some of the books I have read say the header is the programmers explanation/interface to the various tasks he might need to perform for a particular class or task. But..... once you find a header (whether in be a standard C++ or some addon header) how do you know which Library you need to use. I guess I am really asking about the standards since if it is some addon there might be examples and documentation so let's limit this to the standards.
VIEWS ON THIS POST

110

Posted on:

Monday 5th November 2012
View Replies!

Compare diff size uints gives wrong compiler warning?

If I declare a UNUM32 and a UNUM16 variable (see their type defs below) and compare them in an if statement I get W8012 Comparing signed and unsigned values Given that they are both unsigned why is the warning stated in this manner typedef unsigned __int16 UNUM16; typedef __int16 SNUM16; typedef unsigned __int32 UNUM32; typedef __int32 SNUM32;
VIEWS ON THIS POST

198

Posted on:

Wednesday 7th November 2012
View Replies!

custom manipulators gone wrong

sakis.panou@googlemail.com wrote: > I have been trying to create a custom manipulator that takes one > parameter in a very simple class. > I have followed Stroustrup's example in chapter 21 of his 3rd Edition > "The C++ Programming Language", in so far as I understand it, it > should work, however, I do think something very silly is going on here > and for the life of me I just can't see it. I would appreciate any > help you kind folk are willing to impart with. > > I am trying to compile this example with gcc 4.1.2, however, the > output I am getting is: > > main.cpp: In function 'int main(int, char**)': > main.cpp:109: error: no match for 'operator
VIEWS ON THIS POST

104

Posted on:

Wednesday 7th November 2012
View Replies!

Can't figure out what's wrong with this code

Thanks Ian and Suman, that was the problem. I'll make sure I give my friend this lin
VIEWS ON THIS POST

194

Posted on:

Wednesday 7th November 2012
View Replies!

templated func : what's wrong

HI, when trying to compile an embedded version of STL called ustl on win32 platform I get the following error : /// Returns the minimum of \p a and \p b template inline const T1 min (const T1& a, const T2& b) { return (a < b a : b); } 1>c:\program files\microsoft visual studio 8\vc\include\ustl\uutility.h(69) : error C2027: use of undefined type 'T1' 1>c:\program files\microsoft visual studio 8\vc\include\ustl\uutility.h(69) : error C2226: syntax error : unexpected type 'T1' 1>c:\program files\microsoft visual studio 8\vc\include\ustl\uutility.h(69) : error C2988: unrecognizable template declaration/definition 1>c:\program files\microsoft visual studio 8\vc\include\ustl\uutility.h(69) : error C2059: syntax error : '' 1>c:\program files\microsoft visual studio 8\vc\include\ustl\uutility.h(69) : error C2059: syntax error : ')' I think it comes from the fact template functions like this are not standard C++. Could someone confirm How can I change that
VIEWS ON THIS POST

144

Posted on:

Wednesday 7th November 2012
View Replies!

what is wrong with "cout " syntax?? a trial program

Hi all, I have following code that is supposed to increase the power by specified value. int main() { system("cls"); int i, exponent; double base; double new_base=0.0; ofstream powerfile("power.txt",ios::app); cout base; cout exponent; //cout
VIEWS ON THIS POST

83

Posted on:

Wednesday 7th November 2012
View Replies!

something wrong when i compile my own struct

struct lineType { int x, y; lineType(int tx, int ty) { if (tx == 0) { ty = 1 << 20; tx = 1; } x = tx; y = ty; } }; lineType line[30000]; when i compile it error: ...
VIEWS ON THIS POST

108

Posted on:

Saturday 10th November 2012
View Replies!

Binary Arithmetic Add Operator Overloading not compiling, what's wrong ?

, Visual Studio .Net 2005 (Win32) Compile error: Error 1 error C2804: binary 'operator +' has too many parameters line 16 class TSkybuckInt32 { private: int mInteger; public: // constructor with initializer parameter TSkybuckInt32( int ParaValue ); // binary ...
VIEWS ON THIS POST

97

Posted on:

Saturday 10th November 2012
View Replies!

Hi what is the wrong with this code

#include #include using namespace std; void const pring(const int r){ r++; ; cout <<"R IS " << r<
VIEWS ON THIS POST

76

Posted on:

Saturday 10th November 2012
View Replies!

What is wrong with a standard truncate function ?

[cross-posted to comp.lang.c, comp.lang.c++] I see there is now why to truncate a file (in C or C++) and that I have to use platform-specific functions for truncating files. Anyone knows why I mean C/C++ evolved over many ...
VIEWS ON THIS POST

154

Posted on:

Saturday 10th November 2012
View Replies!

This is a wrong code.I just want to know how it affect the compiler,becausethe error message is quite strange.

today I forgot to include some header,then I found the error message by the compiler is quite strange. so I want to know exactly the inner details of the compiler impletation,if possible. and I want to know what does the ...
VIEWS ON THIS POST

338

Posted on:

Saturday 10th November 2012
View Replies!

what's wrong

Turbo C++ I don't know what's happen, this mornig I just added one line of code "hwndParent = GetParent(control);" and get this message: [Linker Fatal Error] Fatal: Access violation. Link terminated....
VIEWS ON THIS POST

49

Posted on:

Sunday 11th November 2012
View Replies!

I was wrong to be here

Maybe I was hoping or hiding. I'm "an elder" and I fucking hate it. But I come here to you to cry. To think about the strength of knowing what few others do and and my own mortality because ... ...
VIEWS ON THIS POST

54

Posted on:

Sunday 11th November 2012
View Replies!

What's wrong with this example

I got an example from trusted cplusplus.com in order to compile and see with Dev C++ 5, but i got a lot of "linker errors - undefined references " or kind of that. I may give the exact source zip ...
VIEWS ON THIS POST

194

Posted on:

Monday 12th November 2012
View Replies!

guys what is wrong here pointer question

int a[3][9]; f(a); void f(int** x) { //do something with a }...
VIEWS ON THIS POST

142

Posted on:

Sunday 25th November 2012
View Replies!

What am I missing? (template magic gone wrong)

>From the following code, what am I doing wrong (I'm using VS2008, which is better at templates than I am, so I assume I'm missing something.) struct SequenceDelete { template void operator()(const ptr_type *p) const { delete p; } ...
VIEWS ON THIS POST

110

Posted on:

Sunday 25th November 2012
View Replies!

Can you spot anything wrong with this class/structure?

I use a game engine using MSVC++ .net 2003 and have no problems. Some users of DevC++ who use the same engine crash at times when a copy of this structure is the return variable. I don't have access to ...
VIEWS ON THIS POST

148

Posted on:

Sunday 25th November 2012
View Replies!

I was/am wrong to be here

I don't know what to say. I don't know why I spent my whole life in R&D. Am I fucking stupid or what...
VIEWS ON THIS POST

32

Posted on:

Sunday 25th November 2012
View Replies!