473,287 Members | 1,533 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

What is this

Hi all,

I am new to C++, so please help me in understanding the below code as
I am not able to
understand, Is this a another way to write the function in C++, and if
yes the any advantage ?

void Update (ctext, input, inputLen)
M_C *ctext; char *input;
unsigned int inputLen;
{
// do some stuff
}
Please Ignore me as I know C.

Thanks
Priya

Jun 2 '06 #1
3 1527
Priya Mishra <mi*******@gmail.com> wrote:
I am new to C++, so please help me in understanding the below code as
I am not able to
understand, Is this a another way to write the function in C++, and if
yes the any advantage ?

void Update (ctext, input, inputLen)
M_C *ctext; char *input;
unsigned int inputLen;
{
// do some stuff
}


This is the old-style (I think it may be called K&R style) C way to
define a function. IIRC it is not allowed in C++. The equivalent C++
definition should be:

void Update(M_C* ctext, char* input, unsigned int inputLen)
{
// do some stuff
}

--
Marcus Kwok
Replace 'invalid' with 'net' to reply
Jun 2 '06 #2
Priya Mishra wrote:
I am new to C++, so please help me in understanding the below code as
I am not able to
understand, Is this a another way to write the function in C++, and if
yes the any advantage ?

void Update (ctext, input, inputLen)
M_C *ctext; char *input;
unsigned int inputLen;
{
// do some stuff
}
This is a very old (and as such non-standard) way of defining a function.
It wasn never part of C++. It was at some point part of C, and IIRC, it
was K&R C. By the time C was standardised this form was replaced with
the full declaration of the arguments between the parentheses.
Please Ignore me as I know C.


Huh??

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 2 '06 #3
Victor Bazarov wrote:
Priya Mishra wrote:

void Update (ctext, input, inputLen)
M_C *ctext; char *input;
unsigned int inputLen;
{
// do some stuff
}


This is a very old (and as such non-standard) way of defining a
function. It wasn never part of C++. It was at some point part of
C, and IIRC, it was K&R C. By the time C was standardised this form
was replaced with the full declaration of the arguments between the
parentheses.


The old-style function definitions are still part of C, although
deprecated. From the C99 draft standard:

6.11.5 Function definitions

[#1] The use of function definitions with separate parameter
identifier and declaration lists (not prototype-format
parameter type and identifier declarators) is an obsolescent
feature.
Basically it's retained due to the tons of legacy code using this
definition style. No new C code should be done that way. C++, as you
say, never had it in a standard version, and I don't if any compilers
supported it in the pre-standard days.


Brian
Jun 2 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Randell D. | last post by:
I have just recompiled, upgraded to PHP 4.3.4. As an exercise (and curiosity) I've decided to test out PDF functions and got the test in the PHP online manual working. I had one problem whereby...
2
by: thecrow | last post by:
Alright, what the hell is going on here? In the following code, I expect the printed result to be: DEBUG: frank's last name is burns. Instead, what I get is: DEBUG: frank's last name is...
220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
9
by: Martin Maney | last post by:
In my copious spare time I've been dabbling at getting a computerized version of a board game working. After deciding that tk just made me want to vomit, and wx was like swimming through...
92
by: Reed L. O'Brien | last post by:
I see rotor was removed for 2.4 and the docs say use an AES module provided separately... Is there a standard module that works alike or an AES module that works alike but with better encryption?...
3
by: Ron_Adam | last post by:
Ok... it's works! :) So what do you think? Look at the last stacked example, it process the preprocess's first in forward order, then does the postprocess's in reverse order. Which might be...
12
by: Dario | last post by:
The following simple program behaves differently in Windows and Linux . #include <stdexcept> #include <iostream> #include <string> using namespace std; class LogicError : public logic_error {...
30
by: James Conrad StJohn Foreman | last post by:
After 3 years of using DB2 on Linux, I'm leaving my current employers to go work for a SQL Server shop instead. In order to find my replacement, they're trying to put together a set of questions...
2
by: yogesh | last post by:
char TCGI::x2c(char *what) { register char digit; digit = (char) ((what >= 'A' ? ((what & 0xdf) - 'A')+10 : (what - '0'))); digit *= (char) 16; digit += (char) ((what >= 'A' ? ((what & 0xdf) -...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.