How do I can display a string value without using the standard libraries in C language? -
how can display string value without using standard libraries in c language? please see following code:
//without using standard libraries other created int main() { string str = "hello"; //how can display str value without using standard libraries other created it? }
here's how can :
// declare prototype write() function, // unspecified parameters because why not. extern long write(); int main(void) { char const *str = "hello"; // retrieve length unsigned long size = 0; while(str[size]) ++size; // write stdout (fd 1) write(1, str, size); return 0; }
of course, it's non-portable gets, , fail link or trigger ub on majority of systems other 1 pulled declaration (it's linux system call, declared in unistd.h
retrieved coliru). then, that's why have standard library in first place.
Comments
Post a Comment