int value in an array to character value

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2008
Posts: 7
Reputation: blackryu21 is an unknown quantity at this point 
Solved Threads: 0
blackryu21 blackryu21 is offline Offline
Newbie Poster

int value in an array to character value

 
0
  #1
Oct 16th, 2008
I need help to change certain values in an Array that I have to a character array.

Here's the code

  1.  
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. char X;
  8. int nROWS = 4;
  9. int nCOLUMNS = 4;
  10. int anArray[4][4] = {{0,1,2,3}, {10,11,12,13}, {20,21,22,23}, {30,31,32,33}};
  11. string headings[4] = {"LA", "CLT", "SVO", "FR"};
  12.  
  13. cout << "\t"<<headings[0]<<"\t"<<headings[1]<<"\t"<<headings[2]<<"\t"<<headings[3]<<endl;
  14. if (anArray[0][0] == 0)
  15. anArray[0][0] == X;
  16. cout << headings[0] << "\t" << anArray[0][0] << "\t" << anArray[0][1]<< "\t" << anArray[0][2] << "\t" << anArray[0][3]<<endl;
  17.  
  18. if (anArray[1][0] == 10)
  19. cout <<"X";
  20. if (anArray[1][1] == 11)
  21. cout << "X";
  22. cout << "\n" <<headings[1] << "\t" << anArray[1][0] << "\t" << anArray[1][1]<< "\t" << anArray[1][2] << "\t" << anArray[1][3]<<endl;
  23.  
  24. if (anArray[2][2] == 22)
  25. cout << "X";
  26. cout << "\n" <<headings[2] << "\t" << anArray[2][0] << "\t" << anArray[2][1]<< "\t" << anArray[2][2] << "\t" << anArray[2][3]<<endl;
  27. if (anArray[3][3] == 33)
  28. cout << "X";
  29. cout << "\n" << headings[3] << "\t" << anArray[3][0] << "\t" << anArray[3][1]<< "\t" << anArray[3][2] << "\t" << anArray[3][3]<<endl;
  30.  
  31. system("pause");
  32. return 0;
  33. }
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 7
Reputation: blackryu21 is an unknown quantity at this point 
Solved Threads: 0
blackryu21 blackryu21 is offline Offline
Newbie Poster

Re: int value in an array to character value

 
0
  #2
Oct 16th, 2008
I don't need int ROWS and int COLUMNS
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 360
Reputation: jencas is just really nice jencas is just really nice jencas is just really nice jencas is just really nice jencas is just really nice 
Solved Threads: 69
jencas jencas is offline Offline
Posting Whiz

Re: int value in an array to character value

 
0
  #3
Oct 16th, 2008
But what is your problem?
If you are forced to reinvent the wheel at least try to invent a better one!

Please use code tags - Please mark solved threads as solved
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 671
Reputation: Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough 
Solved Threads: 113
Freaky_Chris's Avatar
Freaky_Chris Freaky_Chris is offline Offline
Practically a Master Poster

Re: int value in an array to character value

 
0
  #4
Oct 16th, 2008
Not to sure what your actualy problem is but you are assigning X to [0][0] where X is a char that doesn't have a value and is not initialised. So you assign some random value from your memory into the array. NOT GOOD.

Chris
Knowledge is power -- But experience is everything
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC