Skip to content
WJunction - Webmaster Forum

Need some C++ help

Status
Not open for further replies.

Amz

Experienced Member
945
2010
178
Hello guys,

Check this code:

9j9Df.png


Can I declare the value of variables of a structure in this way? If not, is there any other way?
 

7 comments

Can you paste the full code. using
Code:
EDIT:
Maybe you should try creating a class books,
then make Book objects

Also, it won't be scalable and efficient if you Create all the book instances in the Code itself!
 
Can I recomend you:
a) use visual studio. Its a GUI IDE. Although Turbo is oldskool.
b) lookup malloc and memory allocation, thats what you use
 
syntax for structures in C++

PHP:
struct User
{
int userid;
int age;
};
declare a variable of structure :

Assign Values
PHP:
 User user7;
PHP:
user7.userid=7;
user7.age=21;
still using old syntax -_-

start using name spaces ..

PHP:
#include <iostream>
using namespace std;
.
.
.
.
.
.
.
.
 
Can I recomend you:
a) use visual studio. Its a GUI IDE. Although Turbo is oldskool.
b) lookup malloc and memory allocation, thats what you use
I use Turbo C++ because that's what we are asked to use at school. :/ I will look up malloc although I doubt I am going to understand much of it.

@ Desiboy: I know how to make a structure. :P I am just wondering if we can define all the variables of a structure at once. Writing them one by one (like bks[0].name = "ABC"; bks[0].isbn = "123"; ...) will take ages and the code would also look very cluttered. :/
 
yeah..theres a better way..

User user7={7,21};

you can also nest structures .. ( structure in a structure )

if that wont work..get a better compiler + IDE ..
if you want a free one..
Dev C++ is good .
 
if i am not wrong malloc is for c not c++ , in c++ we use new to assign dynamic arrays or pointers , am i right ?
 
Status
Not open for further replies.

About the author

A
Experienced Member · Joined
Graphics designing, football, computers, surfing the internet, building websites, listening music
945
Messages
178
Reactions
43
Points
Grow your business

Advertise on WJunction

Connect with an established international community of webmasters, hosting providers, developers and online entrepreneurs.

  • Premium & Premium+ Sticky
  • Dedicated section banners
  • Site-wide banner advertising
Explore advertising options
Back
Top Bottom