Thread: why the first loop doesnt stop..

  1. #1
    Banned
    Join Date
    Oct 2008
    Posts
    1,535

    why the first loop doesnt stop..

    why the first loop of the function doesnt stop??

    Code:
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    
    typedef struct node node;
    struct node{
    	int value;
    	struct node * next;
    };
     int countletters(char *str);
    void main()
    {
    	int g;
    	char * str="aabx bXcb bBxaDAa";
    	g=countletters(str);
    }
    
    
    int countletters(char *str)
    {
      char ch='a';
      char *st;
      int cnt=0;
      for(st=str;st!='\0';st++)
      {
    	  if ((*str>='A')&&(*str<='Z'))
    	  {
            *str+=32;  
    	  }
      }
       for(;ch<='z';ch++)
       {
          for(st=str;st!='\0';st++)
    	  {
               if (*st==ch)
    		   {
                  cnt++;
    			  break;
    		   }
    	  }
       }
       return cnt;
    }

  2. #2
    Banned
    Join Date
    Oct 2008
    Posts
    1,535
    solved

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Can a "switch" be inside a loop?
    By gmk0351 in forum C Programming
    Replies: 5
    Last Post: 03-28-2008, 05:47 PM
  2. need help, fgets won't stop while loop
    By Enkid in forum C Programming
    Replies: 6
    Last Post: 10-26-2007, 07:15 AM
  3. return to start coding?
    By talnoy in forum C++ Programming
    Replies: 1
    Last Post: 01-26-2006, 03:48 AM
  4. How to change recursive loop to non recursive loop
    By ooosawaddee3 in forum C Programming
    Replies: 1
    Last Post: 06-24-2002, 08:15 AM
  5. 2 largest elements; -1 to stop loop
    By Peachy in forum C Programming
    Replies: 4
    Last Post: 09-16-2001, 05:16 AM