473,473 Members | 1,645 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

not getting the correct answer

6 New Member
Expand|Select|Wrap|Line Numbers
  1.  
  2. #include<stdio.h>
  3. void sqeez(char s1[],char s2[]);
  4. main()
  5. {
  6.     char s1[5];
  7.     char s2[5];
  8.     int i=0;
  9.     int j=0;
  10.     while(i<5){
  11.         s1[i]=getchar();
  12.         ++i;
  13.         }
  14.     while(j<5){
  15.         s2[i]=getchar();
  16.         ++j;
  17.         }
  18.       sqeez(s1,s2);
  19.       return 0;
  20. }
  21.  
  22. void sqeez(char s1[],char s2[])
  23. {
  24.     int i,j,k;
  25.     char s3[5];
  26.     k=0;
  27.     for(i=0;s1[i]!='\0';++i){
  28.         for(j=0;s2[j]!='\0' && s2[j]!=s1[i];++j)
  29.             ;
  30.          if(s2[j]=='\0')
  31.             s3[k++]=s1[i];
  32.             }
  33.             s3[k]='\0';
  34.      while(s3[k]!='\0'){
  35.         printf("%c",s3[k--]);
  36.         }
  37. }
  38.  
my sqeez function deletes any character in s1 which is present in s2...sqeez(s1,s2)....but m not getting any output can anyone tell me what is the error...
Sep 20 '11 #1
2 1156
weaknessforcats
9,208 Recognized Expert Moderator Expert
Your inner for loop is a null loop. Note the terminating semi-colon on line 29.
Sep 20 '11 #2
donbock
2,426 Recognized Expert Top Contributor
stdout is buffered. Try printing a single newline character just before returning from sqeez().
Sep 20 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jonax | last post by:
Hi guys, I have the following code that retrieves a webpage. My problem is getting it to use the right encoding. I've tested it against a danish page, but it won't show the danish characters....
22
by: gabon | last post by:
Hi guys, I'm facing the bug about the failure of innterHTML while reading xhtml content inside a DIV, in fact it has passed as html removing the closing of some nodes. Is there a way to read the...
2
by: mike_li | last post by:
4) If the following commands are executed: UPDATE DBM CFG USING DFT_MON_LOCK OFF UPDATE MONITOR SWITCHES USING lock ON And the DB2 instance is stopped and restarted, the monitor switch for the...
4
by: cmay | last post by:
I am beginning to wonder if it is not possible to get this working. I am trying to do: <root> <a/> <b/> <c/> </root>
23
by: Anders Borum | last post by:
Hi! I am implementing a threaded producer / consumer pattern just for fun. I am using an internal counter to keep track of the produced / consumed items and am logging that information. I am...
8
by: shiniskumar | last post by:
Ive got to sum up 5 numbers. 125000+23500.75+5525725.79+3257500+63542.36 When summing these i should get the answer as 8995268.9 but im getting the answer as 8995268.899999 My script code is...
7
by: Andrus | last post by:
How to get syntactically correct signature which compiles for code template grneration ? I tried code below but it creates syntactically incorrect signature. Andrus. using System; using...
7
mb60
by: mb60 | last post by:
sir In my database I have one column for question. Four columns are meant for options 1,2,3,4. The 5th column is YES/NO column. The answers for the questions are entered into 5th column by a...
5
by: iqra123 | last post by:
hii i m using atoi() to convert char value to int. and then passing that int as a swtich variable. switch goes in a case and exectuing that particualr function but returning 0 value.... for...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.