标签:spl return tom printf \n creat pre const create
//
// 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
标签:spl return tom printf \n creat pre const create
原文地址:http://blog.51cto.com/13959448/2316001