473,325 Members | 2,342 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,325 software developers and data experts.

Control in a vector

Hi to all,

I have this construnct:

......................
char mat [DIM], [DIM]
...................
cout << "Enter the new element" << endl;
for (i=0; i<DIM; i++)
for (j=0; j<DIM; j++)
cin >mat[i][j];
...............................

How can to control, in this construct, that each element is >= 'A' and
<= 'Z'?

Thank You and Best Regards
Gaetano

Nov 18 '06 #1
4 1158
nick048 wrote:
Hi to all,

I have this construnct:

.....................
char mat [DIM], [DIM]
Are you sure you're talking about C++. The above makes no sense.
..................
cout << "Enter the new element" << endl;
for (i=0; i<DIM; i++)
for (j=0; j<DIM; j++)
cin >mat[i][j];
..............................

How can to control, in this construct, that each element is >= 'A' and
<= 'Z'?
if (mat[i][j] >= 'A' | mat[i][j] <= 'Z')
...

But I doubt that you actually want that check. I think you want to check
whether it's an uppercase letter. In this case, you better do:

if (isupper(mat[i][j]) && (isalpha(mat[i][j]))
...

Nov 18 '06 #2
Rolf Magnus wrote:
I think you want to check whether it's an uppercase letter. In this case,
you better do:

if (isupper(mat[i][j]) && (isalpha(mat[i][j]))
...
Ok, stupid me. If a character is an uppercase letter, then it's for sure a
letter, so the isalpha test can be removed:

if (isupper(mat[i][j]))
...

Nov 18 '06 #3
nick048 wrote:
How can to control, in this construct, that each element is >= 'A' and
<= 'Z'?
You must consider that in C++ there is no guarantee that the alphabetic
characters, both in upper and in lower case, are in ascending order and
without gaps. ASCII and extensions of ASCII characters sets has this
property (limited to the characters currently used in english), but C++ is
not limited to that family of character sets. See EBCDIC, for example.

--
Salu2
Nov 18 '06 #4
Hi Rolf.
Are you sure you're talking about C++. The above makes no sense.<<
This is a part of my cpp file:
int main()
{
const int DIM=100;
char mat[DIM][DIM];
char car;
int i, j;
int cont;

/*Reading of the bidimensional matrix*/
cout << "Enter your char" << endl;
for (i=0; i<DIM; i++)
for (j=0; j<DIM; j++)
cin >mat[i][j];
..
..
..
}
The file work correctly.

I need to insert in the "for construct" a control that check if my char
is "uppercase letter".
If the condition is true, the "for loop" continue with the next item;
otherwise it remains.
Best Regards
Gaetano

Nov 18 '06 #5

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

Similar topics

9
by: {AGUT2}=IWIK= | last post by:
Hello all, It's my fisrt post here and I am feeling a little stupid here, so go easy.. :) (Oh, and I've spent _hours_ searching...) I am desperately trying to read in an ASCII...
3
by: Mani | last post by:
Hi, can anyone help me on how to create a control array in C++ builder like we create in VB. I have another question regarding controls. I want to clear a group of text boxes in the form on a...
7
by: Forecast | last post by:
I run the following code in UNIX compiled by g++ 3.3.2 successfully. : // proj2.cc: returns a dynamic vector and prints out at main~~ : // : #include <iostream> : #include <vector> : : using...
34
by: Adam Hartshorne | last post by:
Hi All, I have the following problem, and I would be extremely grateful if somebody would be kind enough to suggest an efficient solution to it. I create an instance of a Class A, and...
8
by: Ross A. Finlayson | last post by:
I'm trying to write some C code, but I want to use C++'s std::vector. Indeed, if the code is compiled as C++, I want the container to actually be std::vector, in this case of a collection of value...
4
by: Mats-Lennart Hansson | last post by:
Hi, Is it possible to create a user control (for a windows application) that is not rectangular but, for example, is like a circle? When I put two controls close each other in a form, you can...
2
by: Hugh Janus | last post by:
Hi all, I am drawing some lines on a picturebox control. In the .Paint event of the picturebox I draw the lines of a graph. These lines are static and never move. Now, in the same Sub I am...
4
by: clintonG | last post by:
Boy that's a helluva subject heh? But that's what I'm looking for. A navigation control that has a series of rectangles (each representing a star in the pattern) where each rectangle is connected...
2
by: archimonde | last post by:
Hi, I am newbie in win32 programming. I need to build a custom control for a news alert desktop application. The application does the following: At WM_CREATE downloads an xml file from an web...
7
by: InteliSavant | last post by:
Hi all, I've had a bit of frustration with making a class and accessing the private variables from the functions. So here's the whole scoop (code snips are located below). I've created my own...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.