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

Array Name

Hello, I need some help with something simple. How would I be able to display two or three names in an array? So, if I have an array calle

Names[ 3 ] = { 10, 10, 10 }; //Names can hold up to three names with 10 characters each. First I want to let the User to type his/her name up to three times. How do I let the make the element in the array count in the while loop??? For example: .... Please help me!!!!!

while ( count < 3 ) // until three names are entere

console :: write( " Please enter your name: ")
// person types in nam
}
Nov 17 '05 #1
2 985
try some thing like this
while ( count < 3 ) // until three names are entered
{
console :: write( " Please enter your name: ");
Name[count].put(); ///like Name[count].gets()
// person types in name
}

or either

CString temp;
char ch;
while(count<3)
{
console::print("Enter ur Name");
while(inner<10)
{
ch = getche();
if( "check for required input")
{
strcat(temp, toStr(ch);
inner++;
}
}
ch = '\0'; \null character
temp = "";
inner = 0;
}
Nov 17 '05 #2
Vas
Have a look at the Array class, all managed arrays inherit from this. It has copy functions and the like

Looking at your example, you've made a wrong assumption, or I have if "Name" means something else

Name[3] = {10,10,10}

This doesn't create 3 strings of 10 characters, it creates an array of 3 elements and each element is initialised with the value 10. When dealing with character strings you'll need to use an array of pointers

char* ptr[3] = {"Name1", "Name2", "Name3"}

This creates an array of 3 pointers to character strings, each one initialised to "Name#" respectively. The length of each element is set to the length of the initialiser

You don't have to initialise straight off though, you can do that when needed

char* ptr[3]

ptr[0] = new char[11]; // 10 for the characters and 1 for the '\0' terminator = 11

This is all low level stuff, from "C". .Net has classes for string manipulation, look at "String" and "StringCollection" classes for more examples

If you want some "C" style examples, checkout the "C" section at www.freshsources.com
Nov 17 '05 #3

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

Similar topics

12
by: James | last post by:
Hi, Have posted before, but will simplify problem here. For original post go to http://forums.devshed.com/t80025/s.html I have setup 2 arrays like so in my one page script: $carers =...
5
by: Nico | last post by:
Hello folks, I am currently storing a set of objects inside an array, $itemlist = array(); $itemlist = new item("myitem"); //... and I am looking to develop a search function, which...
4
by: its me | last post by:
Let's say I have a class of people... Public Class People Public Sex as String Public Age as int Public Name as string end class And I declare an array of this class...
58
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
7
by: Jim Carlock | last post by:
Looking for suggestions on how to handle bad words that might get passed in through $_GET variables. My first thoughts included using str_replace() to strip out such content, but then one ends...
2
by: sicapitan | last post by:
I'm trying to build some xml from an array with the help from another array. In one array I have $cells Array ( =CELL0
23
by: sandy | last post by:
I need (okay, I want) to make a dynamic array of my class 'Directory', within my class Directory (Can you already smell disaster?) Each Directory can have subdirectories so I thought to put these...
2
by: JJA | last post by:
I'm looking at some code I do not understand: var icons = new Array(); icons = new GIcon(); icons.image = "somefilename.png"; I read this as an array of icons is being built. An element of...
1
by: neoblitz | last post by:
Hi Guys, I'm very new to NuSoap. I'm able to call a webservice which actually returned me results.. But I'm having trouble to read the response or I simply don't understand how to read the response.....
33
by: Adam Chapman | last post by:
Hi, Im trying to migrate from programming in Matlab over to C. Im trying to make a simple function to multiply one matrix by the other. I've realised that C can't determine the size of a 2d...
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: 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: 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: 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
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...

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.