The MASM Forum

General => The Campus => Topic started by: Magnum on January 28, 2013, 03:52:58 PM

Title: C+ code ?
Post by: Magnum on January 28, 2013, 03:52:58 PM
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;

Title: Re: C+ code ?
Post by: dedndave on January 28, 2013, 04:04:02 PM
looks like vanilla-flavoured C to me   :P
Title: Re: C+ code ?
Post by: Magnum on January 28, 2013, 04:26:43 PM
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;

Title: Re: C+ code ?
Post by: dedndave on January 28, 2013, 04:38:07 PM
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
Title: Re: C+ code ?
Post by: jj2007 on January 28, 2013, 05:41:25 PM
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:
Title: Re: C+ code ?
Post by: anta40 on January 28, 2013, 06:34:35 PM
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  ;)
Title: Re: C+ code ?
Post by: MichaelW on January 28, 2013, 07:27:56 PM
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:
Title: Re: C+ code ?
Post by: jj2007 on January 28, 2013, 08:38:23 PM
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 ;-)
Title: Re: C+ code ?
Post by: Gunther on January 28, 2013, 09:05:47 PM
Hi Andy,

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

Gunther
Title: Re: C+ code ?
Post by: dedndave on January 29, 2013, 12:34:08 AM
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:
Title: Re: C+ code ?
Post by: qWord on January 29, 2013, 01:17:15 AM
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)]
Title: Re: C+ code ?
Post by: dedndave on January 29, 2013, 01:22:43 AM
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);
Title: Re: C+ code ?
Post by: dedndave on January 29, 2013, 01:34:38 AM
the "this.xxx" is COM - i am starting to get a handle on that   :P
everything else may as well be Greek Russian
Title: Re: C+ code ?
Post by: qWord on January 29, 2013, 01:38:01 AM
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.
Title: Re: C+ code ?
Post by: dedndave on January 29, 2013, 01:39:12 AM
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
Title: Re: C+ code ?
Post by: Magnum on January 29, 2013, 01:57:16 AM
Quote from: dedndave on January 29, 2013, 12:34:08 AM
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


The French and Britains got over the "My navy is bigger than yours."