How to change a value in an array?

I am trying to change a value in my array but the below code simply will not change the value. Is there a certain way to do this? Thanks.
1
2
basicinfotitle=bookinfo[0][0];
cout<<bookinfo[0][0];
Did you mean to write bookinfo[0][0] = basicinfotitle;?
do you want to pass the value to [bookinfo [0] [0]][/code]; if so you can use pointer.
Instead of using a 1x1 array, why not just multiply the two numbers and have a single array? Its the same thing in terms of what the compiler reads. And it looks neater than having the whole
[x][x]
code working.

Just my opinion. Anyways, is basicinfotitle a string? A character array? What is it you're doing? Is bookinfo a 2 dimensional character array?
and have a single array?

a single array? it doesn't even need an array if you're about to declare 1 x 1 array...
When I said 1 x 1 array, I meant to say single dimension array. What his syntax looks to be is a double dimension array. I was just leading to the idea that it doesn't need to be a double dimension array and that a single D array would work just the same.
I need it to be two dimensional because it holds certain information in each. I just want to be able to edit the array from its initial value.

Here is the full code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "hw.h"
#include <string>
#include <iostream>
using namespace std;
string bookinfo[2][3];
int k;
string changes;
int main()
{
	bstore basicinfo;
		
	string basicinfotitle;
	string basicinfoauthor;
	string basicinfoprice;

	int j;
	for(j=0;j<2;j++){
	basicinfotitle=basicinfo.title();
	basicinfoauthor=basicinfo.author();
	basicinfoprice=basicinfo.price();
	
	bookinfo[j][0]=basicinfotitle;
	bookinfo[j][1]=basicinfoauthor;
	bookinfo[j][2]=basicinfoprice;
	
}
	string yesno;
	
	while(yesno!="q"){
cout<<"Enter q to quit at any time"<<endl;	
cout<<"Would you like to display all book info?(yes or no)"<<endl;
cin>>yesno;
if(yesno=="yes"){
	for(j=0;j<2;j++){

	cout<<bookinfo[j][0];
	cout<<bookinfo[j][1];
	cout<<bookinfo[j][2];
	}
}


cout<<"Which book would you like to edit?" <<endl;
cin>>j;
cout<<"Which part woudl you like to edit?"<<endl;
cin>>k;
cout<<"Make changes: "<<endl;
cin>> basicinfotitle;
basicinfotitle=bookinfo[j][k];
cout<<bookinfo[j][k];
	}
//if( 
//cin>>bookinfo[j][k];
}
Thanks. What peter said worked. Can't believe I mixed that up :(
Topic archived. No new replies allowed.