Thread: Quick help !

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

    Join Date
    Jan 2013
    Posts
    11
    Rep Power
    0

    Quick help !


    My fget function is not going through the loop. It is my first time using it. I do not know what I am doing wrong. Please help !

    Code:
    #include<stdio.h>
    
    int main() {
    	char a[5000];
    	char makeCapital = 1;
    	char output[5000];
    	int counter = 0;	
        
    while ((fgets(a,5000,stdin))) {
    
        	int k=0;
    
    	while (a[k] != ' ' && a[k] != '\t' && a[k] != '\r' && a[k] != '\n' && a[k] != 0) {
    
            if ( a[k] >= 65 && a[k] <=90 && makeCapital == 0) { // capital alphabets to small. 
    
    		output[counter] = a[k] + 32;
    						}
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,381
    Rep Power
    1871
    You mean this does nothing?
    Code:
    while ((fgets(a,5000,stdin))) {
      printf("Read line %s", a);
    }
    The biggest problem with your inner loop seems to be a lack of k++.
    Without this, k is stuck at 0, and nothing ever changes.
    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