//
// main.c
//
//
// Created by myhaspl on 2018/10/22.
// myhaspl@myhaspl.com.
//
#include <stdlib.h>
#include <stdio.h>
char mytoken[10];
char* getCord(int placeOnArray, char mystr[80]){
const char s[2] = " ";
char str2[7];
char* token=mytoken;
for (int i=placeOnArray ;i<placeOnArray+7;i++){
str2[i-placeOnArray]=mystr[i];
}
strcpy(mytoken,strtok(str2, s));
printf("%s\n",mytoken);
return mytoken;
}
int main(){
char str[80] = "ATOM 1 N ASN A 1 -4.890 -12.296 -15.280 1.00 30.36 N";
char* token=getCord(17,str);
printf("%s\n",token);
float number=atof(token);
printf( "%f\n", number );
return 0;
}
-4.890
-4.890
-4.890000
©著作权归作者所有:来自51CTO博客作者myhaspl的原创作品,如需转载,请注明出处,否则将追究法律责任
cc++strtok软件设计与架构