473,587 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to make a subarray?

Writing my own algorithm to make a subarray in Visual C++ would be easy enough, but is there a useful function or method for doing this? I have strings stored as TCHAR[] and I want to get substrings of those, but the basic String.substr() function doesn't compile on that. I tried this

TCHAR string[size]
TCHAR substring[size]
//function that returns a value for strin
substring = string->Substring(3, 3)

and I get this when I compile
error C2227: left of '->Substring' must point to class/struct/unio

Thanks in advance!
Nov 17 '05 #1
1 6314
In C++, you cannot assign a value to an array variable. In this case,
you are trying to assign a value to substring, which is illegal.

What you need to do is an element-by-element copy into the substring
array. So you might need something like:

for(int ii = 0; ii < 3; ii++)
substring[ii] = string[ii + 3];
substring[3] = 0;

This will copy 3 characters into substring, starting at index 3 in
string. The last line will null-terminate the string, since it needs to
be in order to be a valid string.

The other option is to use the C++ string class library, instead of
TCHAR arrays.

Thobias Jones
Need Helps wrote:
Writing my own algorithm to make a subarray in Visual C++ would be easy enough, but is there a useful function or method for doing this? I have strings stored as TCHAR[] and I want to get substrings of those, but the basic String.substr() function doesn't compile on that. I tried this:

TCHAR string[size];
TCHAR substring[size];
//function that returns a value for string
substring = string->Substring(3,3) ;

and I get this when I compile:
error C2227: left of '->Substring' must point to class/struct/union

Thanks in advance!

Nov 17 '05 #2

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

Similar topics

3
9996
by: Robert Blaha | last post by:
Hi, I'm runnig Linux/Mandrake9.0-Dolphin and try to update Apache 2.0.46 and PHP 4.3.2. Apache is OK bu with PHP I've problem. I unpacked distribution, run ../configure > configure.vysl, make > make.vysl and make install. When I search in configure.vysl or make.vysl there is nothing about libphp4.so.
1
3796
by: Ante Perkovic | last post by:
Hi, everybody First, the code: --------------------- $maxNo = 500 $numbers = range (1,$maxNo); srand ((double)microtime()*1000000); shuffle ($numbers); $subarray = array_slice ($numbers, 0, 24); ksort ($subarray); // this also don't work!!!
2
5190
by: Glenn | last post by:
Hi, I'm using cygwin and am trying to install DBI-mSQL and am getting errors on make .. any idea how to fix this (TIA): cpan> install DBD::mSQL Running install for module DBD::mSQL Running make for J/JW/JWIED/Msql-Mysql-modules-1.2219.tar.gz LWP not available Fetching with Net::FTP:
9
4179
by: Joel Rodrigues | last post by:
Hi, I get the following error when I run make on Mac OS X v 10.1.5 Any ideas ? ---------------------------------------------------------- ar: illegal option -- s usage: ar -d archive file ... ar -m archive file ... ar -m position archive file ... ar -p archive ar -q archive file ... ar -r archive file ...
8
10685
by: Seeker | last post by:
Hello, In using Solaris Pro Compiler to compile Pro*C code. I am getting this error: make: Fatal error in reader: parser_proc_online.mk, line 26: Badly formed macro assignment Based on other posts, this error is not related to C but related more to my lack of understanding. When I look for line 26 in my make file, it does not correlate...
28
2928
by: Steven Bethard | last post by:
Ok, I finally have a PEP number. Here's the most updated version of the "make" statement PEP. I'll be posting it shortly to python-dev. Thanks again for the previous discussion and suggestions! PEP: 359 Title: The "make" Statement Version: $Revision: 45366 $ Last-Modified: $Date: 2006-04-13 07:36:24 -0600 (Thu, 13 Apr 2006) $
7
2684
by: Steven Bethard | last post by:
I've updated PEP 359 with a bunch of the recent suggestions. The patch is available at: http://bugs.python.org/1472459 and I've pasted the full text below. I've tried to be more explicit about the goals -- the make statement is mostly syntactic sugar for:: class <name> <tuple>: __metaclass__ = <callable>
5
4535
oll3i
by: oll3i | last post by:
why when i try to use subarray (for byte array)function eclipse says it's undefined but i read that this function is defined in java? Thank YOU
0
7920
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8215
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8347
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6626
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5718
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5394
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2358
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 we have to send another system
1
1454
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.