#include <stdio.h>
#include <conio.h>
main()
{     int i;
      char full;
      char array[10]="ABCD";
      for (i=0;i<=6;i++)
          full = array[i];
      
      printf("%c",full);
}

I wanna convert an array to a full character .So that i can print the character like this line printf("%c",full);
This program unable to print the character?? Whats wrong in this prog..??

full can hold only a character. Each time you assign a character to full the previous character in full gets erased.

this might help you.

You can give it like this printf( "%s", array ), why go for copying into something.

#include <stdio.h>
#include <conio.h>
main()
{     int i;
      char full;
      char array[10]="ABCD";   // Create the array with 4 letters followed by \0
      for (i=0;i<=6;i++)       // Loop 7 times
          full = array[i];     // copy the first 7 characters into FULL one 
                               // at a time
      
      printf("%c",full);       // output the value of array[6]
}

You are outputting the character. So what is the value of array[6] ?

Also your array contains 4 chars (A,B,C,D). Why are you running the loop from 0 to 6 ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.