is there any way that I can capitalize argv, such as argv[1] = hello, and argv[2] = world to argv[1] = HELLO, argv[2] = WORLD without using strlen or toupper or copy them into new arry?
#include <stdio.h> int main(int argc, char *argv[]) { if (argc > 1) { int i, j; for (i = 1; i < argc; ++i) { j = 0; while (argv[i][j]) { if (argv[i][j] >= 'a' && argv[i][j] <= 'z') argv[i][j] -= 32; // to change lowercase letter to uppercase letter subtract 32 from letter j++; } printf("%s\n", argv[i]); } } return 0; }
// directly modified argv into uppercase (no libraries used)
Get Answers For Free
Most questions answered within 1 hours.