Hi there,
I have a small issue when I am printing out an array from a user inputted string. The programs function is to have the user input a string and convert all the lower case letters to uppercase without using the toupper function but a self created one. This all works fine but when i print out the array in sequence it always starts with the @ symbol. Is there something that I am doing incorrectly?
Thanks in advance.....Code:#include <stdio.h> #include <string.h> #include <stdlib.h> int checkupper(char*s); int main(void) { // declare the user char arrays to store the strings char user_x1[256] ; char convert; int length; int i,e; int ar_size; printf("Enter a String: "); fgets( user_x1, 256, stdin ); //fgets (char string, int size, file *stream length = strlen(user_x1); printf("%d",length); ar_size=length-1; printf("\n\nlength of the string: %d\n",length); printf("\n\narray size of the string: %d\n",ar_size); system("cls"); for(i=0;i<=ar_size;i++) //for loop to CALL FUNCTION TO CONVERT TO UPPER { convert = checkupper(user_x1); } printf("User converted string: %c",user_x1); for(i=0;i<=ar_size;i++) { printf("%C ",user_x1[i]); } system("pause"); return 0; } int checkupper(char*con) { while(*con)*con>96&*con<123?*con-=32:0,con++; }



LinkBack URL
About LinkBacks



