By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 1,454 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

Generating Bitstream_Showing Compilation Error

P: 1
Hello,

Algorithm: Generating Bitstream (for e.g., 0`s and 1`s)

While compiling this program its showing compiling error. Looking over my program , point out whats wrong in the following codes.

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int bin_verify(char[]);
int main()
{
char bin1[33],bin2[33],result[33];
int len1, lens2,check;
printf("Enter binary number 1:");
scanf ("%s", bin1);
printf("Enter binary number 2:");
scanf ("%s", bin2);
check=bin_verify(bin1);
if(check)
{
printf("Invalid binary number%s.\n", bin1);
exit(0);
}
check =bin_verify(bin2);
if(check)
{
printf("Invalid binary number%s.\n", bin2);
exit(0);
}
printf("output binary %s.\n", bin1);
printf("output binary %s.\n", bin2);
return 0;
}
int bin_verify(char str[])
{
int i;
for (i=0;i<strlen(str);i++)
{
if((str[i]-'0'!=1)&&(str[i]-'0!=0'))
{
return 1;

}
}
return 0;
}
Mar 18 '17 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 2,396
Please provide the text of the compiler error.
Compiler errors typically contain a line number. Which line of your program corresponds to the line number?
Mar 18 '17 #2

weaknessforcats
Expert Mod 5K+
P: 9,197
Other than a couple of unused variables, all I can see is:

Expand|Select|Wrap|Line Numbers
  1. for (i=0;i<strlen(str);i++)
  2. etc...
where int i is signed and strlen() returns a size_t which is unsigned. But even this would be just a warning not an actual error.

What error are you talking about?
Mar 18 '17 #3

Post your reply

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