473,385 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

I have to use so many String arrays

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?
Mar 6 '07 #1
8 1795
Ganon11
3,652 Expert 2GB
So you are creating something like:

Expand|Select|Wrap|Line Numbers
  1. char strings[60][16];
This is 60 * 16 bytes of memory, or 960 bytes of memory - in other words, practically nothing. It is relatively large compared to other variables such as a single int, but I don't think it will be big enough to seriously affect your program's performance time.
Mar 6 '07 #2
So you are creating something like:

Expand|Select|Wrap|Line Numbers
  1. char strings[60][16];
This is 60 * 16 bytes of memory, or 960 bytes of memory - in other words, practically nothing. It is relatively large compared to other variables such as a single int, but I don't think it will be big enough to seriously affect your program's performance time.
I have to create like the following:

string str1[16];
.
.
.
string str60[16];
Mar 6 '07 #3
Ganon11
3,652 Expert 2GB
What you are creating here are 60 arrays of 16 strings. Are you sure this is what you require? I had assumed you meant you needed 60 strings that would hold 16 characters each, not 60 string arrays of 16 strings each.
Mar 6 '07 #4
What you are creating here are 60 arrays of 16 strings. Are you sure this is what you require? I had assumed you meant you needed 60 strings that would hold 16 characters each, not 60 string arrays of 16 strings each.
yes, I am sure about that. now please say, whether the performance will be affected or not?
Mar 6 '07 #5
Ganon11
3,652 Expert 2GB
Well, this will be 60 arrays * 16 entries * 4 bytes, which is 3840 bytes - still not a huge amount. But might I suggest instead of using

Expand|Select|Wrap|Line Numbers
  1. str1[16];
  2. str2[16];
  3. ...
  4. str60[16];
you may consider using a 2D array:

Expand|Select|Wrap|Line Numbers
  1. str[60][16];
Mar 6 '07 #6
Well, this will be 60 arrays * 16 entries * 4 bytes, which is 3840 bytes - still not a huge amount. But might I suggest instead of using

Expand|Select|Wrap|Line Numbers
  1. str1[16];
  2. str2[16];
  3. ...
  4. str60[16];
you may consider using a 2D array:

Expand|Select|Wrap|Line Numbers
  1. str[60][16];
Thank you very much!!!
Mar 6 '07 #7
Banfa
9,065 Expert Mod 8TB
Well, this will be 60 arrays * 16 entries * 4 bytes.
Strictly speaking if using ~4kbytes of memory is a performance issue is platform dependent.

For instance on a PC with 1GByte of RAM then 4kbytes of memory is negligable, however on a microprocessor with 32kbyte of RAM 4kbyte is 12.5% of available memory and could be very significant.
Mar 6 '07 #8
How about just using
Expand|Select|Wrap|Line Numbers
  1. string str60[60]; 
It would work in C++,

would there be a performance issue?
Mar 6 '07 #9

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

Similar topics

3
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...
16
by: Don Starr | last post by:
When applied to a string literal, is the sizeof operator supposed to return the size of the string (including nul), or the size of a pointer? For example, assuming a char is 1 byte and a char *...
4
by: Simon Schaap | last post by:
Hello, I have encountered a strange problem and I hope you can help me to understand it. What I want to do is to pass an array of chars to a function that will split it up (on every location where...
17
by: Chad Myers | last post by:
I've been perf testing an application of mine and I've noticed that there are a lot (and I mean A LOT -- megabytes and megabytes of 'em) System.String instances being created. I've done some...
37
by: jortizclaver | last post by:
Hi, I'm about to develop a new framework for my corporative applications and my first decision point is what kind of strings to use: std::string or classical C char*. Performance in my system...
18
by: greenflame | last post by:
I want to make a function that does the following. I will call it thefunc for short. '||Char>>' I tried the following def thefunc(s): s = "||" + s + ">>"
14
by: rohitpatel9999 | last post by:
Hi While developing any software, developer need to think about it's possible enhancement for international usage and considering UNICODE. I have read many nice articles/items in advanced C++...
9
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,...
3
by: SneakyElf | last post by:
i am very green with c++ so i get stuck on very simple things anyway, i need to write a program that would read data from file (containing names of tv shows and their networks) one line at a time...
3
by: shapper | last post by:
Hello, I have two arrays of strings, s1 and s2: s1 = "london, lisbon, paris, newyork" s2 = "lisbon, yellow, France" s2 will have only one item included in s1.
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
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...

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.