473,499 Members | 1,922 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

string arrays and pointers

3 New Member
Hi, umm i actually have a problem in one of my labs.
I am trying to make a library, where the user initializes multiple books(Object bookType), and their names are saved into a dynamic array called books[1]. i was trying to use pointers to expand the array's size each time a new book is defined.
while running my compiler breaks and gives me an error that "memory access violation" , i do realize that the mistake is because a string doesnt have a consistent size. So how can i know what size each of the names occupies in memory so that i can move that number of locations in memory ????

my code is :

// pb is pointer of books
//NOfB is number of books


Expand|Select|Wrap|Line Numbers
  1. void bookType::setName(string n)
  2. {    name = n;
  3.     cout << n;
  4.     system("pause");
  5.     *(pb+NOfB)= n;
  6.     NOfB++;
  7.     system("pause");
  8.  
  9. }
thank you so much in advance :)
Apr 9 '11 #1
1 1220
whodgson
542 Contributor
Try using a vector instead of an array. load it`s elements with 'push_back'
Apr 10 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
4830
by: Java script Dude | last post by:
Some programmers prefer to stay with native level data structures such as string arrays instead of using Object based data structures such as ArrayList. From and efficiency point of view. Are...
6
12744
by: ASPfool | last post by:
Hello everyone, Please help me before I throw my computer out of the window: I'm working on a web application in classic ASP (vbscript), which is making calls to some webservices. The calls...
5
3737
by: swarsa | last post by:
Hi All, I realize this is not a Palm OS development forum, however, even though my question is about a Palm C program I'm writing, I believe the topics are relevant here. This is because I...
2
1262
by: zlf | last post by:
Hi, This there any existing alorgithm in .NET that can extract the common element in two string arrays to another string array; usage: string a = { "1","2","3" }; string b = { "1" }; string...
9
2081
by: jerry.upstatenyguy | last post by:
I am really stuck on this. I am trying to write a string array containing a "word" and a "definition" to a class called Entry. Ultimately this will end up in another class called dictionary. No,...
0
1133
by: Caffiend | last post by:
Hello again! I am still having problems with the code under the title "newbie woes", but I have moved on for now to another exercise. The book has asked me to write a program that will use two...
1
9393
by: Rick Knospler | last post by:
I am trying to convert a vb6 project to vb.net. The conversion worked for the most part except for the fixed length strings and fixed length string arrays. Bascially the vb6 programmer stored all...
8
1796
by: rsaikamesh | last post by:
Hi All, In my c++ application, I need to use 60 string arrays with the size of 16. If I create this much of arrays, will the performance of my application be affected?
0
1444
by: =?Utf-8?B?YWlhaG1lZA==?= | last post by:
I am trying to call a Webservice written in Java from .NET C# client. I am getting the following error : Exception Details: System.Web.Services.Protocols.SoapException: Server was unable to...
6
3435
by: tshad | last post by:
I am looking for a way to combine 2 string arrays. I am trying to get a list of files from 2 directories and combine them: string strFiles; string strFiles2; strFiles =...
0
7007
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...
0
7174
Oralloy
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,...
0
7220
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6894
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...
0
5470
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4600
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3099
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3091
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.