Skip to main content
Post Reopened by hobbs, Mike, casperOne
added 388 characters in body; edited title
Source Link
Mike
  • 48.7k
  • 30
  • 116
  • 179

printf function not functional() isn't being executed

I waswanted to write a program which counts the occurrences of each letter in a string, then prints one of each letter followed by the count for that turns "aabbcccd" into"a2b2c3d1"letter.

For example:

aabbcccd - But whatHas 2 a, 2 b, 3 c, and 1 d

So I'd like to convert and print this as:

a2b2c3d1

I wrote code (givensee below) mysteriously produced noto perform this count/conversion but for some reason I'm not seeing any output.

#include<stdio.h>
main() 
{
    char array[]="aabbcccd";
    char type,*count,*cp=array;
    while(cp!='\0'){
      type=*cp;
      cp++;
      count=cp;
      int c;
      for(c=1;*cp==type;c++,cp++);
      *count='0'+c;
    }
    count++;   
    *count='\0';
    printf("%s",array);
}

Can anyone help me understand why I'm not seeing any output from printf()?

printf function not functional

I was to write a program that turns "aabbcccd" into"a2b2c3d1" But what I wrote(given below) mysteriously produced no output

#include<stdio.h>
main(){
  char array[]="aabbcccd";
    char type,*count,*cp=array;
   while(cp!='\0'){
    type=*cp;
    cp++;
    count=cp;
    int c;
    for(c=1;*cp==type;c++,cp++);
     *count='0'+c;
   }
   count++;   
   *count='\0';
   printf("%s",array);
}

printf() isn't being executed

I wanted to write a program which counts the occurrences of each letter in a string, then prints one of each letter followed by the count for that letter.

For example:

aabbcccd - Has 2 a, 2 b, 3 c, and 1 d

So I'd like to convert and print this as:

a2b2c3d1

I wrote code (see below) to perform this count/conversion but for some reason I'm not seeing any output.

#include<stdio.h>
main() 
{
    char array[]="aabbcccd";
    char type,*count,*cp=array;
    while(cp!='\0'){
      type=*cp;
      cp++;
      count=cp;
      int c;
      for(c=1;*cp==type;c++,cp++);
      *count='0'+c;
    }
    count++;   
    *count='\0';
    printf("%s",array);
}

Can anyone help me understand why I'm not seeing any output from printf()?

Post Closed as "not a real question" by djechlin, Rob, Guvante, Dharmendra, brenjt
Source Link
EthOmus
  • 59
  • 2
  • 6

printf function not functional

I was to write a program that turns "aabbcccd" into"a2b2c3d1" But what I wrote(given below) mysteriously produced no output

#include<stdio.h>
main(){
  char array[]="aabbcccd";
    char type,*count,*cp=array;
   while(cp!='\0'){
    type=*cp;
    cp++;
    count=cp;
    int c;
    for(c=1;*cp==type;c++,cp++);
     *count='0'+c;
   }
   count++;   
   *count='\0';
   printf("%s",array);
}