CSC209H5 Chapter Notes - Chapter 3: Gnu Compiler Collection, Entry Point, Gold Base

16 views3 pages

Document Summary

Csc209h5s - software programming and tools (winter 2018) // declare a string literal char *s = "17"; #include int main() { char *s = "17" ; // below is one way to convert from string to integer. // below is the most appropriate way to convert int i = strtol(s, null , 10 ); printf( "i has the value %d\n" , i); return 0 ; long int strtol( const char *str, char **endptr, int base); Strtol string to long s string to convert. Null uses middle column to tell leftover parts of the string starts (address from pointer to char); used as a starting point [see below] 10 base of the number we are converting to (usual number system) Long can be stored as an int. int main() { char *s = "-17 is the number! char *leftover; //pointer to char (char *)

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents