i have a program in c++ and i want to do it in visual c++, but i found a problem, in the code program made in c++ i use a type struct :
struct ind
{
char *c;
int f;
}
but i think that in visual c++ doesn’t exist the type struct , i'm not sure..... can i use the type struct in VISUAL C++ or what other kind of struct may i use
i think that is the main question.... WHAT other type can i use instead of the struct in visual c++ , i want to declare two variables of the type ind:
ind pob;
ind pob2;
so i can use the structure pob[0].c, pob[1].c , pob[1].f ........
please HELPPPPPPPPPPPPP

how can i use the type struct in VISUAL C++??... i'm new in visual c++
netsql
but my question is... can i use the TYPE STRUCT in VISUAL C++
WN3335
a similar type in VISUAL C++..... that is my problem..... because i'm doing the program in VISUAL C++
Are you missing something i don’t know....
Matt Michuta
TYPE STRUCT IN visual c++
the code that i wrote HERE is in c++ , and i want to do it in VISUAL C++....
Stephanie Barulic
If your code does something like:
struct ind
{
char *c;
int f;
};
Then yes that is supported in VC++ which is visible in the above example.
P.S:Make sure you have the ";" after "}" cause wasn't there in your previous sample (probably a typo).
Alan Smith MVP
I believe what you mean is how to use an array of structs.
Here is a sample of what you can do:
#include <stdio.h>
#include <string.h>
struct ind
{
char *c;
int f;
};
void main()
{
ind pob[5];
ind pob2[5];
pob[0].f = 10;
pob2[0].c = new char[10];
strcpy (pob2[0].c,"In main");
printf ("number = %d ... string = %s",pob[0].f,pob2[0].c);
}
This should output:
number = 10 ... string = In main
Davidarh
You can define your own if you want.
Am I missing something
Thanks,
Ayman shoukry
VC++
Vikas Bindra
Mo_Fya
Here is a pointer on how structs work in VC++:
http://msdn.microsoft.com/library/default.asp url=/library/en-us/vclang/html/_clang_structure_declarations.asp
Also, you can use typedef to define your struct:
#include <stdio.h>
#include <string.h>
typedef struct
{
char *c;
int f;
} STRUCT;
void main()
{
STRUCT pob[5];
STRUCT pob2[5];
pob[0].f = 10;
pob2[0].c = new char[10];
strcpy (pob2[0].c,"In main");
printf ("number = %d ... string = %s",pob[0].f,pob2[0].c);
}
Thanks,
Ayman Shoukry
VC++
norax
sorry, new in visual c++
Intruder
The "struct" is C++ (VC++) is an aggregate of components of other types.
Thanks,
Ayman Shoukry
VC++