how to copy a string without using c function

Answer Posted / ruchi

#include<stdio.h>
#include<conio.h>
int main()
{
char a[40],b[40];
int i=0,c,j;
printf("\nEnter the first string ");
while((a[i++]=getchar())!='\n');
for(c=0;c<i;c++)
{
b[c] = a[c];
}

for(j=0;j<i;j++)
{
printf("%c",b[j]);
}
getch();
}

Is This Answer Correct ?    3 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How will you delete a node in DLL?

688


Is a pointer a kind of array?

602


Describe static function with its usage?

616


I need testPalindrome and removeSpace #include #define SIZE 256 /* function prototype */ /* test if the chars in the range of [left, right] of array is a palindrome */ int testPalindrome( char array[], int left, int right ); /* remove the space in the src array and copy it over to the "copy" array */ /* set the number of chars in the "copy" array to the location that cnt points t */ void removeSpace(char src[], char copy[], int *cnt); int main( void ) { char c; /* temporarily holds keyboard input */ char string[ SIZE ]; /* original string */ char copy[ SIZE ]; /* copy of string without spaces */ int count = 0; /* length of string */ int copyCount; /* length of copy */ printf( "Enter a sentence:\n" ); /* get sentence to test from user */ while ( ( c = getchar() ) != '\n' && count < SIZE ) { string[ count++ ] = c; } /* end while */ string[ count ] = '\0'; /* terminate string */ /* make a copy of string without spaces */ removeSpace(string, copy, ©Count); /* print whether or not the sentence is a palindrome */ if ( testPalindrome( copy, 0, copyCount - 1 ) ) { printf( "\"%s\" is a palindrome\n", string ); } /* end if */ else { printf( "\"%s\" is not a palindrome\n", string ); } /* end else */ return 0; /* indicate successful termination */ } /* end main */ void removeSpace(char src[], char copy[], int *cnt) { } int testPalindrome( char array[], int left, int right ) { }

2220


What is string concatenation in c?

570






What does c mean?

592


Where does the name "C" come from, anyway?

647


What is linear search?

678


What is meant by initialization and how we initialize a variable?

590


How can I trap or ignore keyboard interrupts like control-c?

621


What is difference between far and near pointers?

614


What is this infamous null pointer, anyway?

613


int i=10; printf("%d %d %d", i, i=20, i);

1018


a way in which a pointer stores the address of a pointer which stores the value of the target value a) reference b) allocation c) multiple indirection d) none

631


What is extern c used for?

571