473,379 Members | 1,544 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,379 software developers and data experts.

Size constraints in C++

Hi,
I am doing a program with data compression and was wondering if there are any sort of limits on vectors that I did not know about. The program works perfectly as long it is under about 2100 characters, however, if I try to compress anything longer it encodes it, but when I decode it it gives me really random symbols 箸ق㧰ف獲潩㵮ㄢ〮•湥潣楤杮∽楗摮 like these along with a lot of extra boxes. I thought it was a character array at first, but I switched all of them to vectors and it still does this.

Thanks for any help,
husker14
May 31 '07 #1
7 1565
weaknessforcats
9,208 Expert Mod 8TB
A vector containing what type?

vector<T>::max_size() will give you the number of elements you can have in the vector. This says nothing about the size of the elements.

I have personally used a vector of a million doubles with no problem.

But this:
program works perfectly as long it is under about 2100 characters
doesn't say what it is.

Those odd characters look like a display of non-ASCII values which makes me think you have some memory corruption operating.
May 31 '07 #2
It is a vector of chars, if that helps.
Jun 1 '07 #3
weaknessforcats
9,208 Expert Mod 8TB
unless there is a way to convert wchar_t to char?
A vector is an array. The C++ spec specifically says vector must implement a C array. Therefore, if your code works with a char array it will work as a vector.

Now you mention encoding/decoding and you mention a vector of char. I assume you meant a vector of unsigned char. Right?
Jun 1 '07 #4
JosAH
11,448 Expert 8TB
A vector is an array. The C++ spec specifically says vector must implement a C array. Therefore, if your code works with a char array it will work as a vector.

Now you mention encoding/decoding and you mention a vector of char. I assume you meant a vector of unsigned char. Right?
The (Chinese?) characers I saw in the OP's example have unicode values far
beyond the range [0,255]. My guess is that the vectors are at least vectors of
unsigned shorts or some utf/8 decoding must be trying to decode those values.
Without seeing any code all I can conclude is that there's definitely something
rotten in the state of Denmark ;-)

kind regards,

Jos
Jun 1 '07 #5
AdrianH
1,251 Expert 1GB
Given all the info so far, I'd say it is a problem with your compression algorithm. It is very doubful that it is related to the STL vector class. It should be able to hold (at least) 2.1GiB as long as your OS and computer requirements supports it.

2100 is about 11 bits so I don't see why around that number would cause a problem.


Adrian
Jun 1 '07 #6
I figured out what was going wrong. The problem was an integer was getting too big and so it was turning it into a negative number and screwing everything up.
Thanks for all of your help.
Jun 1 '07 #7
AdrianH
1,251 Expert 1GB
I figured out what was going wrong. The problem was an integer was getting too big and so it was turning it into a negative number and screwing everything up.
Thanks for all of your help.
No prob.


Adrian
Jun 1 '07 #8

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

Similar topics

0
by: Merlin_1102 | last post by:
I have read previous posts on the gridbaglayout and none seem to answer my questions (sorry if any of these have been aske dI really did search and found one large thread which took me an hour to...
18
by: Xiangliang Meng | last post by:
Hi. void setValue(int n) { int size = getValueLength(); int buffer_p; if (buffer_p) { ....
4
by: Dmitri | last post by:
I just looked at a coworker's stored procedure and this person is dropping 4 Foreign key constraints and then re-adding them after processing the required logic (updating rows in the 4 tables in...
2
by: Kums | last post by:
What is the maximum permissible size of a database? Is there any limitation. What is the maximum # of tablespace's allowed in a database? Thanks for your response.
22
by: Wynand Winterbach | last post by:
I think every C programmer can relate to the frustrations that malloc allocated arrays bring. In particular, I've always found the fact that the size of an array must be stored separately to be a...
12
by: siliconwafer | last post by:
Who decides size of data types in C? Is it the: 1.C standard and hence the compilers 2.Operating System.
7
by: Kai-Mikael Jää-Aro | last post by:
Here is an example HTML file: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Test!</title> </head> <body>...
30
by: Neil | last post by:
Yikes! My database, which had been consistently 1 gig for a long time, went from being 1 gig to 3 gigs overnight! Looking at the nightly backups, the database increased on average about 5-15 MB per...
18
by: MisterE | last post by:
I hear that this isn't always valid: FILE *in; long size; in = fopen("foo.bar","rb"); fseek(in,0,SEEK_END); size = ftell(in); fseek(in,0,SEEK_SET); then fread size many bytes into memory.
7
by: Luna Moon | last post by:
#include "stdafx.h" #include <iostream> #include <string> using namespace std; int main() { string cc(31, 'c'); string bb=cc.assign(3, 'dd');
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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?

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.