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

Editing values in an array..

Hi everyone!

What is the best way to be acble to change values in an array?

For example, if i have an array declared like this:

int a[] = {1, 2, 3, 4, 5, 6};

how can i change those values later on on the program? Like say those are the initial values but, i would like a keyboard listener so that the user can manually change those numbers him/herself.

OR

can i initialize an array like this:


int a[] = {int x1, int x2, int x3, int x4, int x5, int x6};\

and then change the values this way.
Any suggestions, what am i doing wrong I appreciate all the help

Thanks,

Gabe
Oct 5 '06 #1
1 1697
r035198x
13,262 8TB
Hi everyone!

What is the best way to be acble to change values in an array?

For example, if i have an array declared like this:

int a[] = {1, 2, 3, 4, 5, 6};

how can i change those values later on on the program? Like say those are the initial values but, i would like a keyboard listener so that the user can manually change those numbers him/herself.

OR

can i initialize an array like this:


int a[] = {int x1, int x2, int x3, int x4, int x5, int x6};\

and then change the values this way.
Any suggestions, what am i doing wrong I appreciate all the help

Thanks,

Gabe
To change a value in an array at position i in an array do

a[i] = newValue;

where newValue is the value you want to assign to position i.
e.g to replace 3 with 8 in your array above, you do

a[2] = 8;

remember array indexing starts at 0.
Oct 6 '06 #2

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

Similar topics

4
by: Dan Weeb | last post by:
Hi All, I have struggled through this far with help from many of you so thanks. I am stuck again. I am really new to this so don't be harsh :-) There are a few problems. You can run the script...
0
by: Sebi | last post by:
Hello All, I'm having problems, reading the new Values from CheckBox in a DataGrid. my Code Behind is C# I do exactly what other samples do, but I allways get the Initial Values instead of...
5
by: Ian Bicking | last post by:
I got a puzzler for y'all. I want to allow the editing of functions in-place. I won't go into the reason (it's for HTConsole -- http://blog.ianbicking.org/introducing-htconsole.html), except that...
3
by: Andrea | last post by:
The Gridview's RowDeleting event, give the power - cycling the e.Keys Dictionary, to discover the values of the Primary key fields of the dataset setup throught the DataKeyNames. Since I want to...
3
by: Sonnich | last post by:
Hi I have a file with some configation in it... I am wondering how I correct single values in there. The most secure is to recreate the file, then rename it. But is there a way to correct a...
0
by: Frenchie | last post by:
I have a Gridview with a checkbox on each row. I would like to be able to select 1 or more rows and edit one of the fields in each of these rows. Basically, I dont want my users to have to edit...
0
by: Frnak McKenney | last post by:
Can I use a bound ComboBox for both browsing and editing? I'm working on a small, standalone database application using Visual C#.NET 2003 and an Access data file. In order to keep the number...
4
by: helenwheelss | last post by:
Access 2003, using a bound form. I'm seeing rather annoying behaviour when editing data in a control with a default value. It only happens when the form is on a new record. A specific...
4
by: ASPnewb1 | last post by:
Hello, I have a 2-dimensional array created from the following text file: data1=asdfawe data2=2 data3=223d data4=22
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
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
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,...
0
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...
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.