- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello developers,
I have some question related transporting chracter variable from Fortran to C.
Here are my codes:
# In Fortran
CHARACTER URL*128
URL='http://***.**.***.**/url/something.php?inf=some&tm=200001011200'
WRITE(URL(49:59),'(A10)') YYYYMMDDHH
CALL URLOPEN(IU, URL)
# In C
urlopen(int *ret, char* url) {
printf("%s \n", url);}
# Result
'http://***.**.***.**/url/somethine.php?inf=some&tm=200001011200' #7777END
One odd thing is that it is okay in character length under 128(127,126,..).
Is there any problem to think about in the current situation? Is there a problem if the char length in C exceeds 128?
Please let me know if there is the way to use a longer length character because the length of URL may increase.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
C strings are null terminated, so add a char(0) at the end of your fortran string.
There is no limit for C string length.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Vautier,
Thank you for your help.
I understand what you are answering but I don't know how to fix this because I am not be good at C programming enough.
Additionally I have one more question to fix my problem.
The rest of C code is below:
urlopen(int *ret, char* url)
{
char *prul;
printf("%s \n", url);
purl = _fcdtocp(url);
handle = url_fopen(purl, "r");
}
In the case that url is "http://some_url #7777END", url_fopen process does not successed.
Please let me know how to modify this purl or url string?
ex1) purl = _fcdtocp(url(0:nlength-2))
ex2) CHARACTER URL(0:128)
URL="http://***.**.***.**/url/something.php?inf=some&tm=200001011200"
URL(0)=" "
ex3) or something
Thank you,
Kihang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the fortran code, add //char(0) at the end of the url= statement.
Nothing to do on C side.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page