why the first loop doesnt stop..

This is a discussion on why the first loop doesnt stop.. within the C Programming forums, part of the General Programming Boards category; why the first loop of the function doesnt stop?? Code: #include <stdio.h> #include <string.h> #include <stdlib.h> typedef struct node node; ...

  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, 02: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21