main(int argc, char *argv[])
the second parameter, argv, to function main takes a pointer to an array.
can we also write it in terms of a reference rather than a pointer ? (like &..) 4 3416
> main(int argc, char *argv[]) the second parameter, argv, to function main takes a pointer to an array.
can we also write it in terms of a reference rather than a pointer ? (like
&..)
The main function has been defined to have those parameters, and you can not
change that definition.
In addition argv is an array and arrays can not be referenced as a reference
can not be indexed.
Niels Dybdahl
m sergei wrote: main(int argc, char *argv[])
the second parameter, argv, to function main takes a pointer to an array.
No, it doesn't. It takes a pointer to a pointer. can we also write it in terms of a reference rather than a pointer ? (like &..)
If you mean whether you can write main in such a way that it takes a
reference to an array, the answer is no (typically).
If you mean whether you can use a reference to an array as function
parameter in general, the answer is yes:
#include <iostream>
void foo(int (&x)[3])
{
x[0] = 1;
x[1] = 2;
x[2] = 3;
}
int main()
{
int array[3];
foo(array);
std::cout << array[0] << ' ' << array[1] << ' ' << array[2] << '\n';
}
m sergei posted: main(int argc, char *argv[])
the second parameter, argv, to function main takes a pointer to an array.
can we also write it in terms of a reference rather than a pointer ? (like &..)
I know that in your own head you may just think of a reference as a const
pointer, and this is may even be the way a certain compiler works with them
in certain places, but the thing is that it doesn't have to, the Standard
does specify how the behaviour of references is to be achieved, just *that*
it is achieved. For example:
int main()
{
double k;
double& p = k;
p = 53.2342;
}
There won't be a pointer there.
-JKop This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: lkrubner |
last post by:
I've written some template code and one thing I'm trying to protect
against is references to images that don't exist. Because users have
the ability to muck around with the templates after...
|
by: Greg Hurlman |
last post by:
I've got what I'm sure is a very simple problem. In an ASP page, I am trying
to write out 4 fields from a recordset in succession:
Response.Write rs("LastName")
Response.Write rs("Suffix")...
|
by: Rob McLennan - ZETLAND |
last post by:
Hi, I'm relatively clueless when it comes to correct ASP syntax. I'm
testing out a search form for my company's website which is done in
ASP. The results are displayed as per the code shown at the...
|
by: Ian Shere |
last post by:
I have an FAQ page on my site, but, because much of the information could be
relative to the area council's bylaws, I want to have a pop-up window appear
when someone clicks the "FAQ's" menu...
|
by: Kristian Nybo |
last post by:
Hi,
I'm writing a simple image file exporter as part of a school project,
and I would like to write completely platform-independent code if at all
possible. The problem I've run into is that...
|
by: Sune |
last post by:
Hi!
Pre-requisites:
-------------------
1) Consider I'm about to write a quite large program. Say 500 K
lines.
2) Part of this code will consist of 50 structs with, say, no more
than at most...
|
by: seema_coma |
last post by:
Hi all,
I am new to C programming,
All I just need to know is how to write the
following in C,
if (open STDOUT){
close the STDOUT
}
Can anyone guide me
Thanks
|
by: Jeroen |
last post by:
Hi all,
I've got a question about writing a library. Let me characterize that
library by the following:
* there is a class A which is available to the user
* there is a class B that is used...
|
by: CK |
last post by:
How do I write a set based query? I have a groupSets table with fields
setId, idField, datasource, nameField, prefix, active
Data:
1,someIDfield, someTable, someField, pre1, 1
2,someotherIDfield,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |