/*
* Copyright ©2026 Soham Pardeshi. All rights reserved.
* Permission is hereby granted to students registered for University of
* Washington CSE 333 for use solely during Summer Quarter 2026 for
* purposes of the course. No other use, copying, distribution, or
* modification is permitted without prior written consent. Copyrights
* for third-party components of this work must be honored. Instructors
* interested in reusing these course materials should contact the author.
*/
#include <stdio.h> // printf, sscanf
#include <stdlib.h> // strtol, EXIT_SUCCESS
int main(int argc, char** argv) {
int num; // holds return values
char* p_end; // holds endptr output param for strtol
char* str1 = "333 rocks";
int i; // output param for sscanf
char str2[10]; // output param for sscanf
num = (int) strtol(str1, &p_end, 10);
printf("*** STRTOL ***\n");
printf("converted number = %d\n", num);
printf("str1 = %p\n", str1);
printf("p_end = %p\n\n", p_end);
num = sscanf("3 blind mice", "%d %s", &i, str2);
printf("*** SSCANF ***\n");
printf("filled %d arguments\n", num);
printf("i = %d\n", i);
printf("str2 holds: %s\n", str2);
return EXIT_SUCCESS;
}