Skip to content
Snippets Groups Projects
Commit 5dc177c3 authored by Paul Russo's avatar Paul Russo
Browse files

Fix usage of string constant.

git-svn-id: http://root.cern.ch/svn/root/trunk@24868 27541ba8-7e3a-0410-8455-c3a389f83636
parent 9ca620ae
No related branches found
No related tags found
No related merge requests found
...@@ -5,72 +5,66 @@ ...@@ -5,72 +5,66 @@
* For the licensing terms see the file COPYING * For the licensing terms see the file COPYING
* *
************************************************************************/ ************************************************************************/
// Start of tt.C
#include<iostream> #include <iostream>
using namespace std; using namespace std;
void prna( char (*p)[5][7]) // It doesn't work in CINT
void prna(char (*p)[5][7]) // It doesn't work in CINT
{ {
#if 0 cout << "casted value of p[1][1]:" << (char*) &p[1][1] << endl;
cout<< "prna value of p :" << (void*) p << endl; cout << "value of p[1][1] :" << p[1][1] << endl;
cout<< "prna loc of p[1][1] :" << (void*)&(p[1][1])<<endl; const char* str = p[1][1];
#endif cout << " I see:" << str << endl;
cout<< "casted value of p[1][1]:" << (char*)&(p[1][1])<<endl; cout << endl;
cout<< "value of p[1][1] :" << p[1][1] <<endl;
const char *str = p[1][1];
cout << " I see:" << str << endl;
cout << endl;
} }
void prnc(char p[][5][7]) //Call by reference It doesn't work in CINT
void prnc(char p[][5][7]) // Call by pointer to first element It doesn't work in CINT
{ {
#if 0 cout << "casted value of p[1][1]:" << (char*) &p[1][1] << endl;
cout<< "prnb value of p :" << (void*) p << endl; cout << "value of p[1][1] :" << p[1][1] << endl;
cout<< "prnb loc of p[1][1] :" << (void*)&(p[1][1])<<endl; const char* str = p[1][1];
#endif cout << " I see:" << str << endl;
cout<< "casted value of p[1][1]:" << (char*)&(p[1][1])<<endl; cout << endl;
cout<< "value of p[1][1] :" << p[1][1] <<endl;
const char *str = p[1][1];
cout << " I see:" << str << endl;
cout << endl;
} }
void prnb( char *p[5][7]) void prnb(const char* p[5][7])
{ {
#if 0 cout << p[1][1] << endl;
cout<< (void*) p << endl;
#endif
cout<<p[1][1]<<endl;
} }
void zsendarray() void zsendarray()
{ {
char a[3][5][7] = { {"aaa","bbb","ccc","ddd"} char a[3][5][7] = {
,{"eee","fff","ggg"} {"aaa", "bbb", "ccc", "ddd"}
,{"iii","jjj","kkk","lll"} , {"eee", "fff", "ggg"}
}; , {"iii", "jjj", "kkk", "lll"}
char* b[5][7] = { {"aaa","bbb","ccc","ddd"} };
,{"eee","fff","ggg"} const char* b[5][7] = {
,{"iii","jjj","kkk","lll"} {"aaa", "bbb", "ccc", "ddd"}
}; , {"eee", "fff", "ggg"}
cout << &(a[0][0][0]) << endl; , {"iii", "jjj", "kkk", "lll"}
cout << &(a[0][1][0]) << endl; };
cout << &(a[0][2][0]) << endl; cout << &a[0][0][0] << endl;
cout << &(a[0][3][0]) << endl; cout << &a[0][1][0] << endl;
cout << &(a[1][0][0]) << endl; cout << &a[0][2][0] << endl;
cout << &(a[1][1][0]) << endl; cout << &a[0][3][0] << endl;
cout << &a[1][0][0] << endl;
#if 0 cout << &a[1][1][0] << endl;
cout << "start of a: " << (void*)a << endl; cout << endl;
cout << "loc of a[1][1]: " << (void*)&(a[1][1][0]) << endl; prna(a);
#endif prnc(a);
cout << endl; prnb(b);
prna(a);
prnc(a);
prnb(b);
} }
void t1157() { zsendarray(); } void t1157()
{
int main() {zsendarray(); return(0);} zsendarray();
}
int main()
{
zsendarray();
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment