#C problem
2 messages in this thread
Hello,
I have a problem.
I will exchange some chars to others.
I like to create a table of chars like those:
char conv={1,2,3,4,5,6,7,8,9,10}
This table should hold all chars they exists on AMIGA machines. They should
changed to PC chars.
I have a string in: char buffer[255];
I would create a stringpointerlist with strbpl().
Then I would test every char with thos routine:
while(c) {
c=conv[c];
c++; }
(c is a pointer to the strbpl() list).
May someone help me?
Thanks…
Christian
Known as: SYSOP@apd.insider.sub.de 8.5 GBytes Online
Christian_Benner%2:245/6613.8 Mailbox: +49 6384 7582
> while(c) {
> c=conv[c];
> c++; }
There is one definite problem I can see with your while loop. It will only
finish when c becomes NULL but since you are incrementing it c will go
past the end of the array and into the wilds of RAM.
Also, if c is the value that the SAS documentation refers to as s which is
the pointer to the string pointer list, c=conv[c] will not work. I think
what you need is something more like this, but I may be wrong :
for ( i=0 ; i<n ; i++)
{
for ( j=0 ; s[i][j] ; j++ )
s[i][j] = conv[ s[i][j] ] ;
}
n is the value returned by strbpl, s is the pointer to the string pointer
list, i and j are integers used for indexing and conv is your conversion
array. Since s points to an array of pointers to arrays of characters you
need an outer loop to step through the pointers and an inner loop to step
through the characters.
Peter Wade
Autopiloting from London, England