Last active
January 15, 2023 18:53
-
-
Save coinconclusive/7ba04129af2f4342f6cb9420430c0e47 to your computer and use it in GitHub Desktop.
Revisions
-
coinconclusive revised this gist
Jan 15, 2023 . 1 changed file with 8 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,13 @@ // this compiles with -Wall -Wpedantic -Werror // int s2i(char**s,int*n){ int z=1;for(*n=0;**s>47 ;z*=10)*n=*n*10+*(*s)++ -48;;return z;}void s2f (char**s,float*f){int n ,z;s2i(s,&n);*f=n;+**s^ 46?0:(*f+=(++*s,z=s2i(s ,&n),(n+0.f)/z));}/*a*/ // example usage: // -
coinconclusive revised this gist
Jan 15, 2023 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,6 +13,10 @@ // example usage: // #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char s1[] = "123.456"; char *s2 = malloc(8); -
coinconclusive created this gist
Jan 15, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ // this compiles with -Wall -Wpedantic -Werror // /*****************************/ /**/int s2i(char**s,int*n){/**/ /**/int z=1;for(*n=0;**s>47/**/ /**/;z*=10)*n=*n*10+*(*s)++/**/ /**/-48;;return z;}void s2f/**/ /**/(char**s,float*f){int n/**/ /**/,z;s2i(s,&n);*f=n;+**s^/**/ /**/46?0:(*f+=(++*s,z=s2i(s/**/ /**/,&n),(n+0.f)/z));}/*annie*/ /*****************************/ // example usage: // int main() { char s1[] = "123.456"; char *s2 = malloc(8); memcpy(s2, s1, sizeof(s1)); char *s3 = s2; float x; s2f(&s3, &x); printf("%s -> %f\n", s2, x); free(s2); }