Problem in String replace program's output


Posted on 16th Feb 2014 07:03 pm by admin

Hi all,
I was trying to make a program which accepts a string and replaces it with another string accepted using pointers.The code following is error free but on executing it doesnot produce correct result.I have supplied the output below the code. Help me to fix the error.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include #include void main() { char *str,*str1; clrscr(); printf("n Enter the string"); gets(str); printf("n Enter the string with which you want to replace 1st string"); gets(str1); printf(" string are : t"); puts(str); printf("t"); puts(str1); while(1) { if(*str1 !='') { *str=*str1; ++str; ++str1; } if(*str1 =='') { break; } } printf("n New String is t"); puts(str); getch(); }
Output Enter the string Suvo Enter the string with which you want to replace 1st string k string are Suvo k New String is uvo
Also please tell me how can I print the current character pointed bu a char pointer(string). For testing the behavior of pointers inside the while loop I tried using printf but it shows weird chars like splecial chars(play button, heart, spade etc)

Thanks in advance

No comments posted yet

Your Answer:

Login to answer
311 Like 41 Dislike
Previous forums Next forums
Other forums

Ajax Error since Upgrading to 3.5
Ever since upgrading my site to .NET 3.5 (I needed LINQ), I've been getting this annoying error on o

Help with search.php
Hello All

I need the search engine on a site I am building at the moment to display the searc

Delete Client 066 Earlywatch
Hi all,

in former times client earlywatch was required for SAPs remote access to SAP inst

Form Help
Here is the form:

Line number On/Off | Expand/Contract<? include("../include/sess

Required to login help
I'm trying to set up my site so users have to be logged into the forum to access the site.I've been

Need a fuction to count entries in a field
Hi
I need a fuction to count how many times a email address is entered in to a field.

I ma

pointer 102 question
I read a book
1
2
3
4
5
6
7
8
9
10
11
12
int main() {

1,000 select boxes with 100 options?!
I have 1 drop down select box with 1,000 options.


In some case, there will be 100+ of the

Is this possible? If one file assigned to an ID...
I have a page that lists property listings assigned to a specific user (a manage page), with brief t

True way to see if action was successful?
If this is a good way to see if action was successful to continue:

Code: function changeGa

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash