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

New to C++ and have a couple of questions

HI everyone, I am just starting to learn C++, I started with learning
php and have found that some of the syntax is similar.Please excuse if
this question is a bit nieve. I was wondering if their was a regex
library for c++, I have found using regular expression in php to be
most helpfull. In C++ from what I have read is that you have to list
the size of your arrays before you fill them. I would think that
regular expression would make this easier if you have an undetermined
size of an array and also for splitting configuration files too. Any
help would be greatly appreciated.
Aug 30 '08 #1
1 1030
dsims wrote:
HI everyone, I am just starting to learn C++, I started with learning
php and have found that some of the syntax is similar.
It may be similar, but beware of the numerous subtle differences.
In C++ from what I have read is that you have to list
the size of your arrays before you fill them.
Arrays in C++ are not at all like those in PHP. Don't let the fact that
the word "array" is used in both languages confuse you.

In C++, arrays are a very low-level (and broken) language structure
which you should hardly ever use. There are container classes which you
should use instead. Unlike PHP, which has those built-in arrays that try
to serve all kinds of different purposes at the same time, C++ offers
container classes for solutions to particular problems.

For example, look at std::vector, std::set and std::map.

http://www.parashift.com/c++-faq-lite/containers.html

Here's a simple example:

#include <vector>
#include <iostream>

int main()
{
std::vector<intnumbers;
numbers.push_back(123);
numbers.push_back(456);
numbers.push_back(789);

for (std::vector<int>::const_iterator iter = numbers.begin();
iter != numbers.end(); ++iter)
{
std::cout << *iter << "\n";
}
}
Even if you use arrays, you don't have to know their size beforehand if
you allocate them dynamically. However, that should not even bother you.
Just use the standard container classes and you'll be fine.
--
Christian Hackl
Aug 30 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: dasacc | last post by:
(1) How do I perform a search for "word" and have it return every line that this instance is found? (2) How do I perform a search for "word" and "wordtwo" at the same time to return every line...
19
by: chris | last post by:
Hello, I've recently been trying to understand the various structures supplied by c++, and the one I find most confusing is deque. One quick question about this. It seems most implementations...
2
by: PointNot | last post by:
I'm coding in Dev C++ by bloodshed my questions are.... I want to learn to create GUI windows interfaces, can I do it in here. I've never learned the visual aspect of C++ yet, and would like to...
2
by: dave | last post by:
trying to make adjustments to my 'position fixed' nav menu, but can't seem to get it centered, no matter how hard I try: this jumbled-mess can be viewed at: http://hardwares.po.gs/menu_test/ ...
4
by: Jim S | last post by:
A number of functions that I use regularly in Access, either in queries or reports, have stopped working within the last couple of days. They include: Left() InStr() Now() When run in a...
21
by: Rob Somers | last post by:
Hey people, I read a good thread on here regarding the reason why we use function prototypes, and it answered most of my questions, but I wanted to double check on a couple of things, as I am...
3
by: punt | last post by:
I've got a couple of questions about a deployed VB.NET application. Firstly can a deployed application remember any variables(single string) after being closed down and re-opened, without the use...
7
by: Marc | last post by:
Hi, I'm working with a customer that is trying to find a solution to provide geographical redundancy. Our application is currently using IBM DB2 v8.2. I have a couple of questions with regards...
9
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will...
158
by: madhawi | last post by:
This question is occur in interview. Please help me.
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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...

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.