1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Rep Power

    String manipulation

    Hey guys,

    I wrote the following code so far(at the very bottom), which asks the user to input a string less than 100 characters such as "Programming's Hard!"

    I am trying to get it so that the program will be able to restate the string that the user entered above, but do three things differently:
    1) switch it to all capital letters if its not already in capital,
    2) remove any spaces that may be in the string
    3) remove any no alphabetic symbols (i.e. '!')

    the output should look like this:

    Enter String: Programming's Hard!

    String to Encode: PROGRAMMINGSHARD

    If you guys could help me understand how to do any of the three things, i would really appreciate it, i am really lost as to how to go about it.


    #include <stdio.h>
    #include <string.h>
    //Define all Variables
    char string[100];
    int count;      
    // Prompt User to Enter String
    int array[27]= {0b0001,0b001111,0b10110,0b00000,0b011,0b11011,0b001100,0b1001,0b0100,
    int main() {
    printf("Enter String: ");
    scanf("%s", string);
    for(count=0; count<=strlen(string); count++) { 
       if(string[count]>97 && string[count] >= 122)
    printf(" String to Encode: %s", string);
    while(strcmp(string, "quit")); 
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Rep Power
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper

IMN logo majestic logo threadwatch logo seochat tools logo