[quote=“Axel”]Actually I might have found part of the problem:
TString *T = (TString*) Strings[j];
Strings is a TObjArray*, so Strings[j] will give you the j-th TObjectArray in the TObjectArray-array, that Strings points to (think of “const char* arr” where arr[j] will give you the j-th character). What you want is
TString *T = (TString*) (*Strings)[j];
Also, try to run your macro after calling “.O0”. The var Strings not being known in the loop might be caused by Cint’s loop optimization, which is disabled by “.O0”.
Axel.[/quote]
Hi Axel,
I am not sure you are right. Like in the sample program at the end
the elements of the char* array can be reached without dereferencing,
same way should go in the attached sample program, using the attached data.
Using the demo unmodified, i.e. “#if 1”, CINT has the same opinion: the output is
root [0] .L mydemo.C
root [1] mydemo()
1=116.45
1=17243
1:(2 tokens) =116.4 17203.3
token #0 @261b6b8’
Error: Can’t call TObjArray::After(T) in current scopedemo.C LINE:35tutorials\my
Possible candidates are…
filename line:size busy function type and name (in TObjArray)
(compiled) 0:0 0 public: virtual TObject* After(TObject* obj) const;
filename line:size busy function type and name (in TSeqCollection)
(compiled) 0:0 0 public: virtual TObject* After(TObject* obj) const=0;
filename line:size busy function type and name (in TCollection)
filename line:size busy function type and name (in TObject)
Error: non class,struct,union object $(*Strings) used with . or ->mo.C LINE:35de
*** Interpreter error recovered ***
root [2]
After modifying the source, i.e “#if 0”, the output is
root [3] .L mydemo.C
root [4] mydemo()
1=116.45
1=17243
1:(2 tokens) =116.4 17203.3
token #0 @262b248’
i.e. the number of the tokens in the line is correctly recognized,
the address of the TString received is not wrong, and even ROOT
aborts when trying to access the TString.
Any ideas? Pleasy try them on the attachments.
Regards
Janos
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
main()
{
unsigned int k;
char hello = malloc(6);
strcpy(hello,“Hello”);
printf(“length of ‘%s’ =%i\n”,hello,strlen(hello));
for(k = 0; k<strlen(hello); k++)
{ printf("%c", hello[k]); }
printf("\n");
/ for(k = 0; k<strlen(hello); k++);
{ printf("%c", (hello)[k]); }
This results in:
C:\veghj\projects\wx\ewa\iotest.c(14) : error C2109: subscript requires array or pointer type
Error executing cl.exe./
}
Mydemo.C (2.6 KB)