AlistairMonkeyFinger
Programmer
Hello,
you'll have to excuse how i ask this question because i am not a C programmer (sorry!) but i am writing a small program using a set of third party libraries to do some scientific calculations.
I can post some code if you like, but basically the problem is that i have what i would call a string..
char *smiles;
and i have some code that takes some data from an external database call (ignore the dt_stringvalue function)
This string is actually two strings separated by a pipe so i split them up...
work out where the pipe is..
get the first string up to the pipe..
At this point everything is ok, i can output my string to the console at it looks good....
Now, here's my problem. Only for certain strings, when i call third party functions that do not involve the smiles string, then output the smiles string, it has an extra character appended (sometimes a "9" sometimes a "n" with a squiggle over it, sometimes something different) i.e.
where smirks is a different string, then i output the smiles string it has changed. Is it something to do with memory allocation ? pointers ?
For example, when i use..
Nc1cccc(c1)S(=O)(=O)O.c1ccccc1C(=O)O|([*;$([NX3][C,c]):1][H]).([*;$([CX3](=O)[OX2;H1]):2][*;$([OH]),$(OC(=O)C):99])>>[*:1][*:2].[*:99][H]
everything is fine, but when i use..
CN1C(=O)CN=C(c2ccccc2)-c3cc(Cl)ccc13|[*;$([CX3](=O)[NX3]):1](=O)>>[*:1]([H])[H]
The smiles string (characters up to the pipe) gets extra characters appended after i call other functions.
I'm sorry if i haven't explained myself too well, i'm more than happy to supply any further information, thanks for any tips you can give me.
Alistair
you'll have to excuse how i ask this question because i am not a C programmer (sorry!) but i am writing a small program using a set of third party libraries to do some scientific calculations.
I can post some code if you like, but basically the problem is that i have what i would call a string..
char *smiles;
and i have some code that takes some data from an external database call (ignore the dt_stringvalue function)
Code:
str = dt_stringvalue(&lens, sob); /*str is what the user gave us*/
Code:
char *search_char = "|";
tsmirks = strstr(str, search_char);
Code:
index = str - tsmirks;
Code:
smiles = (char *)calloc(index, sizeof(char));
strncat(smiles, str, index);
Code:
fprintf(stderr, "SMILES ok: %s \n", smiles);
Code:
if (NULL_OB == (xform = dt_smirkin(strlen(smirks), smirks))) {
fprintf(stderr, "SMIRKS bad: %s \n", smirks);
} else {
fprintf(stderr, "SMIRKS loaded into transform ok: %s \n", smirks);
}
For example, when i use..
Nc1cccc(c1)S(=O)(=O)O.c1ccccc1C(=O)O|([*;$([NX3][C,c]):1][H]).([*;$([CX3](=O)[OX2;H1]):2][*;$([OH]),$(OC(=O)C):99])>>[*:1][*:2].[*:99][H]
everything is fine, but when i use..
CN1C(=O)CN=C(c2ccccc2)-c3cc(Cl)ccc13|[*;$([CX3](=O)[NX3]):1](=O)>>[*:1]([H])[H]
The smiles string (characters up to the pipe) gets extra characters appended after i call other functions.
I'm sorry if i haven't explained myself too well, i'm more than happy to supply any further information, thanks for any tips you can give me.
Alistair