Thread: comparing of charaters in a given string from input string

  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    10

    comparing of charaters in a given string from input string

    I am stuck in this program please remove the error and send back to me.


    Be given a string of chars, where each single char belongs to the following alphabet: a..zA..Z0..9 (So, in the string there are only lowercases, uppercases and digits. No blank, no comma, ...).
    For every char of the given alphabet, count how many times in the string


    1-- the char belong to a sequence of identical chars whose length is at least three (i.e.: in the string cc74uyrpfccc348fhsjcccc3848djccccc484jd for three times the character 'c' satisfies this condition)


    Code:
    #include<stdio.h>
    #include<conio.h> 
    #include<string.h>
    main()
    {
        char* alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        int alphalength[] = strlen(alphabet);
          char str[100];
    
     int i,j,count,f1,f2,l=1;
    
      printf("Enter string\n");
      gets(str);
      int strlenght[] = strlen(str);
      
      for (i=0; i < alphalength; i++) 
      {
          count=0;
          for (j=0; j<=strlength; j++)
          {
           if (strlength[j] == alphalength[i])
           count=1;
           
          
           if (strlength[j+1] == alphalength[i+1] && strlength[j+2] == alphalength[i+2])
           
            }
          
            printf("%c", j);
            count+2;
                }
              while(j=count);
                 }
                 
                }
                
                getch();  
    }
    2-what is the longest substring of characters strictly rising interm of ASCII code(the following is greater (>) of the previous)

    3- what is the longest substring of successive characters interm of given string rannge (i.e.: fhkjshdfruytyzABCDEfglsj => 7)
    Last edited by tahir123; 02-07-2013 at 04:59 AM.

  2. #2
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    You have errors in your program that should be caught by your compiler. Fix those first, or post the message here if you don't understand what the compiler is telling you. For example, you misspelled strlength, and you forgot to put anything after your second `if'. There are probably more errors.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 12-09-2011, 02:52 AM
  2. Replies: 13
    Last Post: 11-04-2011, 06:16 PM
  3. comparing user input with a string
    By Shingetsu Kurai in forum C++ Programming
    Replies: 5
    Last Post: 08-06-2011, 10:34 PM
  4. Problem comparing string from text file with string constant
    By XenoCodex Admin in forum C++ Programming
    Replies: 3
    Last Post: 07-25-2002, 10:17 AM
  5. string comparing
    By TED22_8 in forum C Programming
    Replies: 13
    Last Post: 01-21-2002, 11:05 AM