Sunday, July 12, 2009

How to make c programs using strings?

Since u hvn't stated the problem, I'm giving a simple example :





/*to reverse an entered string*/


#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;


main()


{


char a[50];


int i,j=0,k=0,t,n;


clrscr();


printf("enter string");


gets(a);


for(i=0;a[i]!=NULL;i++)


{


j++;


}


j--;


do


{


t=a[j];


a[j]=a[k];


a[k]=t;


k++;


j--;


}while(k%26lt;=j);


puts(a);


getch();


}





U can run the above program, let u've entered "SCIENCE", it'll give output reversed "ECNEICS".





For any program in C-code(related strings), u can ask me through mails.

How to make c programs using strings?
C programs to do what exactly? Any program that uses text will use strings - strings are the data type that stores text.





Try searching the internet for C programming tutorials. The information you are after exists in many different forms in many different places already. To repeat it here would be a waste of time and resources.





Rawlyn.


No comments:

Post a Comment