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

Assigning a value to an array

i need to assign a value to an array but it is not in the normal way, here is the code so far:
Department[1] = "Accounts";
Department[2] = "Teller";
Department[3] = "Loans";
Department[4] = "Operations";
Department[5] = "Personnel";
Nov 24 '11 #1

✓ answered by johny10151981

in c you cannot just assign a literal string.

use strcpy function, if you are using wide string use wcscpy but if you are using multibyte string you better use strncpy but strcpy will do the same purpose

5 2481
johny10151981
1,059 1GB
in c you cannot just assign a literal string.

use strcpy function, if you are using wide string use wcscpy but if you are using multibyte string you better use strncpy but strcpy will do the same purpose
Nov 25 '11 #2
whodgson
542 512MB
declare the array like this....note the first element in an array is element[0].
string Department [6]= {"","Accounts","Teller","Loans:,"Operations","Pers onnel"};
Nov 27 '11 #3
donbock
2,426 Expert 2GB
Do you intend to skip the first element in the Department array; that is, Department[0]?

I can think of several possibilities for the type of array variable Department. What did you choose for its type? Each data type has a preferred way to do assignments.
Nov 28 '11 #4
an example of how this could be done??
could this work:
strcpy ( department1, "Accounts" );
Dec 1 '11 #5
donbock
2,426 Expert 2GB
What is the type of array variable Department?

Do the values of the Department array change while the program runs or do the initial values persist?
Dec 2 '11 #6

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

Similar topics

5
by: Robert Oschler | last post by:
I am converting a Perl script over to "C" for a potential open source project. I need some open source "C" code that will give me the same functionality of a Perl Style associative array: ...
1
by: Steve Caliendo | last post by:
Hi, How do I set a variable to be null? I want to update a set in a database, and in some cases I would like a particular field to remain unchanged, or null. I'm building a query string based...
3
by: astro | last post by:
this must be obvious and i'm missing it............... i want to have 4 checkboxes in a groupbox - box1 value = 1, box2 = 2, box3 = 4, box4 = 8 these ctrls are not bound...I want to assign...
0
by: dd | last post by:
Hi, I have the following code and want to assign value to a 3D arrays and print it out. But it seems that the value 1 hasn't been assigned to that array. Could anyone help me out? Thank you very...
2
by: | last post by:
Hi everyone, I have a form with a combo box on it. When you select a value (a PO#) from the combo box, the bound field is the indexID of the selected PO. On the same form, I have a text box...
2
by: huzzaa | last post by:
I am trying to get the user to input 1-10 and that will select a a number from an array and place it into a variable. here is the code. do { cout << "Enter the first row...
4
jeffbroodwar
by: jeffbroodwar | last post by:
Hello, i have a problem about assigning a char value to a byte... please check the code below : ======================================================== Scenario # 1 : This code doesn't work : ...
1
by: Neil Chambers | last post by:
I'm currently using multidimensional arrays in PoSH by assigning values to index positions. I'm doing this because AFAIK there is no way to initialise an array simply with the 'number' of...
8
by: getmeidea | last post by:
Hi, I am using JDK 1.5. I have a program like this. Here i am directly assigning value to one object. It does'nt give me any compile time or run time error. In java we dont have access to any...
20
by: Shalini Bhalla | last post by:
i am not able to assign values ,can any one tell me whats wrong .... <script> function changeMySrc(nm,act) { alert("hi"+ nm ); if(act == 1) { ...
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?
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
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,...
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
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,...

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.