News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

C+ code ?

Started by Magnum, January 28, 2013, 03:52:58 PM

Previous topic - Next topic

Magnum

Is this C+ by chance ?

I recognize the cout statements from maybe 10 years ago.

I found C+ harder to understand than C and writing batch files.

If you are a perfectionist, the next sentence may show that I have recovered.  :t

I may  "übersetzen das Kode." (schlecht Grammatik - Es tut mir leid) :-)

   static DWORD ThreadProc(PARAMETERS * data){
   fnBeep beep=(fnBeep)data->BEEP;a
   fnMessageBoxA msgbox=(fnMessageBoxA)data->MSGBOX;
   beep(data->freq,data->time);
   msgbox(data->hWnd,data->text,data->title,data->type);

ANDLE hProcess=OpenProcess(PROCESS_ALL_ACCESS,false,PID);
   if(hProcess==NULL){
   cout <<"\nUnable to open process handle.\n\n";
   return 1;

Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

dedndave

looks like vanilla-flavoured C to me   :P

Magnum

I think we both have early state dementia.



iostream(C++std)

cerr , cin , clog , cout , wcerr , wcin , wclog , wcout - defines the iostreams objects that manipulate the standard streams
Synopsis

   namespace std {
   extern istream cin;
   extern ostream cout;

Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

dedndave

ahhh yes - didn't see that
usually, i know i am not interested when i see "methods" (functions) that have periods in them   :P
i guess that is .NOT stuff

jj2007

Where do you see dots, Dave? To me it looks like the standard ++ variant of Chinese ;-)
They don't print, they cout - which sounds a bit like shout. Indeed the compiler shouts at you if you forgot to put the ";". Not "can't find the end of the line" (which would make sense) but rather something really weird indicating it desperately tried to merge the current with the next line, and it didn't make sense etc...
The arrows in msgbox(data->hWnd,data->text,data->title,data->type); say "these are DWORDs". Don't believe what the documentation says! These are DWORDs, trust me 8)

Finally, ANDLE hProcess indicates "ce code a été écrit par un français". The French cannot pronounce the H, so they often omit it :biggrin:

anta40

Judging by the invocation of cout, it's C++.
Anyway, valid C code is usually also a valid C++ code, but not the other way around  ;)

MichaelW

Jochen,

The semicolon is not an EOL marker it's a statement separator. The creators had the foresight to design the language so you can impress people with code like this:

#include <conio.h>
#include <stdio.h>
#include <windows.h>
__inline int popcount_mult(UINT32 x){UINT32 m1,m2,m4,h01;m1=0x55555555;m2=0x33333333;m4=0x0f0f0f0f;h01=0x01010101;x-=(x>>1)&m1;x=(x&m2)+((x>>2)&m2);x=(x+(x>>4))&m4;return(x*h01)>>24;}
void main(void){printf("%d\n",popcount_mult(1));printf("%d\n",popcount_mult(2));printf("%d\n",popcount_mult(3));getch();}


:biggrin:
Well Microsoft, here's another nice mess you've gotten us into.

jj2007

Quote from: MichaelW on January 28, 2013, 07:27:56 PM
Jochen,

The semicolon is not an EOL marker it's a statement separator.

:biggrin:

Michael,

Early BASIC dialects used : to achieve the same effect. Then mysteriously their authors dropped that "feature". Maybe I should stop making fun of the semicolon, the joke is getting stale ;-)

Gunther

Hi Andy,

the code looks like C++ for me. Could you post the entire source file, please?

Gunther
You have to know the facts before you can distort them.

dedndave

QuoteFinally, ANDLE hProcess indicates "ce code a été écrit par un français". The French cannot pronounce the H, so they often omit it :biggrin:

Brits are like that also
didn't think the Brits and the French had much in common - lol

i think it's a miss with copy/paste, though   :P

(that's not a typo - guess we can call it a "copyo" ?)

as for the dots - i don't see any in that code
but, i see them in other code - is that C# i think ?
i just know that when i see a function that has a period, i close that page and search elsewhere   :lol:

qWord

Quote from: dedndave on January 29, 2013, 12:34:08 AMas for the dots - i don't see any in that code
but, i see them in other code - is that C# i think ?
In C and C++ the dot is used to access a structure(===class) member. The arrow operator is used to dereference a structure/class pointer (it is a short form of (*pStruct).member, whereas * is the dereference operator).
For C# the dot is used for member access.
[However, because the arrow operator also exist in c# (usable in 'unsafe'-blocks), it is maybe also possible to use the arrow operator for that access (I've never seen that)]
MREAL macros - when you need floating point arithmetic while assembling!

dedndave

so......
everything is a structure ???

string className = this.GetType().FullName;
System.Reflection.MethodInfo[] methods = this.GetType().GetMethods();
foreach (var method in methods)
    Console.WriteLine(method.Name);

dedndave

the "this.xxx" is COM - i am starting to get a handle on that   :P
everything else may as well be Greek Russian

qWord

Quote from: dedndave on January 29, 2013, 01:22:43 AMeverything is a structure ???
No, the methods of your example simply return further objects, which can access that way: e.g. this.GetType()  returns an object with member FullName.
MREAL macros - when you need floating point arithmetic while assembling!

dedndave

all i know is, i have no way of turning that into assembler - lol
i am sure it can be done - i haven't gotten that far
that may not be the best (worst) example of what i mean