void main()
{
int a={1,2,3,4,5,6,7,8,9,10};
int *p=a;
int *q=&a;
cout<<q-p+1<<endl;
}
The output is 10, how?
if we give cout<<q it will print the address, value won't print....
if we give cout<<p it will print the address, value won't print....
p has the base addr; q... (1 Reply)
All ..
I am having a pointer array . And trying to store the addess into that pointer array . please see below the problem i faced
code:
int cnt1;
char *t_array;
char *f_array;
for(cnt1=0; cnt1<1000; cnt1++)
{
t_array =... (1 Reply)
If one wants to get a start address of a array or a string or a block of memory via a function, there are at least two methods to achieve it:
(1) one is to pass a pointer-to-pointer parameter, like:
int my_malloc(int size, char **pmem)
{
*pmem=(char *)malloc(size);
if(*pmem==NULL)... (11 Replies)
Hi all,
Can anyone provide help with getting the right syntax regarding array/pointers in C in the following code? Can't locate a specific example which clarifies this...
Say I declare a typedef to an array of pointers to some type...
/**
* An array of ptrs to sections
*/
typedef... (4 Replies)
if i create an array of pointers to a structure "struct node" as:
struct node *r;
and create "n" number of "linked lists" and assign it to the various struct pointers r using some function with a return type as structure pointer as:
r=multiplty(.......) /*some parameters*/
is... (2 Replies)
Hi guys,
Besides the points bellow, what would best practices for scripting be ?
1) set the PATH
2) unset the current environment (set -u ?)
3) (re)set the IFS to default value - space (IFS="" <- is this correct ?)
4) check the return code for each action inside the script (cd, rsync,... (1 Reply)
I am struggling with the pointer to 2D-array (cf: 2D array of pointers). Can anybody help me elaborate how the pointer x moves in the memory to access the individual of y, especially the high lighted lines?
I have talked to one of the curators of the forum, but I am still not quite clear.
Here... (1 Reply)
Discussion started by: yifangt
1 Replies
LEARN ABOUT DEBIAN
pgacreate
PGACreate(8) PGAPack PGACreate(8)NAME
PGACreate - creates an uninitialized context variable. The Fortran version of this function call contains only the last three arguments
INPUT PARAMETERS
argc - address of the count of the number of command line arguments.
argv - array of command line arguments.
datatype
- the data type used for the strings. Must be one of PGA_DATATYPE_BINARY, PGA_DATATYPE_CHARACTER, PGA_DATATYPE_INTEGER,
PGA_DATATYPE_REAL, or PGA_DATATYPE_USER
binary -valued, character-valued, integer-valued,
real -valued, or a user-defined datatype, respectively.
len - the string length (number of genes).
maxormin
- the direction of optimization. Must be one of PGA_MAXIMIZE or PGA_MINIMIZE for maximization or minimization, respectively.
OUTPUT PARAMETERS
none
SYNOPSIS
#include "pgapack.h"
PGAContext * PGACreate(argc, argv, datatype, len, maxormin)
int *argc
char **argv
int datatype
int len
int maxormin
LOCATION
create.c
EXAMPLE
Example:
In C:
void main(int argc, char **argv) {
PGAContext *ctx;
:
ctx = PGACreate(&argc, argv, PGA_DATATYPE_BINARY, 100, PGA_MAXIMIZE);
:
// Set options here
:
PGASetUp(ctx);
:
// Run the GA here
:
PGADestroy(ctx);
}
In FORTRAN:
integer ctx
:
ctx = PGACreate(PGA_DATATYPE_BINARY, 100, PGA_MAXIMIZE)
:
c Set options here
:
call PGASetUp(ctx)
:
c Run the GA here
:
call PGADestroy(ctx)
stop
end
05/01/95 PGACreate(8)