I wrote this code, but I'm not able to test it because im getting 3 errors. So I'm not sure that this code will work properly or not!!!
the code in -
#include <stdio.h>
-
#include <stdlib.h>
-
int rnd(char s1[],char s2[],char c[]);
-
int GetSt(char s1[],char s2[],char c[]);
-
void SearchAndPrint (char s1[], char s2[], char c[], int length);
-
-
int main ()
-
{
-
char s1[41];
-
char s2[21];
-
char c[2];
-
int answer,m;
-
while(answer !='n')
-
{
-
m=rnd(s1,s2,c);
-
if (m==-1)
-
{
-
printf("ERROOORRR\n");
-
printf("wanna cont press enter or n to exit\n");
-
answer=getchar();
-
continue;
-
}
-
else
-
{
-
printf("wanna cont press enter or n to exit\n");
-
answer=getchar();
-
}
-
return 0;
-
}
-
-
-
-
-
-
int rnd(char s1[],char s2[],char c[])
-
{
-
int i,n;
-
for(i=0;i<41;i++)
-
s1[i]=rand() %26 + 'A';
-
s1[i]='\0';
-
-
n=GetSt(s1,s2,c);
-
if(n==-1)
-
return -1;
-
else
-
return 1;
-
}
-
-
-
int GetSt(char s1[],char s2[],char c[])
-
{
-
int n,i,length,m;
-
printf("enter a char\n");
-
c[0]=getchar();
-
if((n=getchar())!='\n')
-
{
-
printf("ERROOORRR\n");
-
while(n!='\n')
-
{
-
n=getchar();
-
}
-
return -1;
-
}
-
c[1]='\0';
-
-
printf("enter char\n");
-
i=0;
-
while(i<21)
-
{
-
if( (m=getchar()) !='\n')
-
{
-
if('A'<=m && m<='Z')
-
{
-
s2[i]=m;
-
i++;
-
}
-
else if ('a'<=m && m<='z')
-
{
-
m=m-32;
-
s2[i]=m;
-
i++;
-
}
-
else
-
{
-
while(m!='\n')
-
m=getchar();
-
break;
-
}
-
-
}
-
else
-
{
-
s2[i]='\0';
-
break;
-
}
-
}
-
length=i;
-
if(i==21)
-
{
-
printf("error 2\n");
-
while(m!='\n')
-
m=getchar();
-
return -1;
-
}
-
else if(i<2)
-
{
-
printf("error 3\n");
-
return -1;
-
}
-
else
-
{
-
SearchAndPrint(s1,s2,c,length);
-
return 1;
-
}
-
}
-
-
-
void SearchAndPrint (char s1[], char s2[], char c[],int length)
-
{
-
int i,j;
-
char cha;
-
-
for (i=0;i<length;i++)
-
{
-
cha=s2[i];
-
for(j=0;j<41;j++)
-
{
-
if(s2[j]==cha)
-
{
-
s2[j]=c[0];
-
continue;
-
}
-
else
-
{
-
continue;
-
}
-
}
-
}
-
puts(s1);
-
puts(s2);
-
puts(c);
-
}
-
And im getting 3 errors like: -
:\Temp\lab213.c(36) : error C2143: syntax error : missing ';' before 'type'
-
I:\Temp\lab213.c(39) : error C2065: 'i' : undeclared identifier
-
I:\Temp\lab213.c(43) : error C2065: 'n' : undeclared identifier
-
Note: All the above errors are about the function
int rnd(char s1[],char s2[],char c[])
Please help!!!!!
2 1363
You're missing a } to close main().
rand() returns a double. Use (char) to cast to char so it goes into your array.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: terry |
last post by:
I am a programmer (cobol, peoplesoft, sqr, etc.) so I am familiar
with programming logic, etc. but not very familiar with C. I need a C
program in a study I'm doing. The program is fairly simple,...
|
by: Dr_Z2A |
last post by:
Ok so a couple months ago I wrote a currency converter and never got it
to compile (my memorization of syntax sucked then) and I just had the
printed out copy lying in a stack of papers. So I...
|
by: genestarwing |
last post by:
QUESTION:
Write a program that opens and read a text file and records how many
times each word occurs in the file. Use a binary search tree modified
to store both a word and the number of times it...
|
by: punkybrewster |
last post by:
I need to write a program that will compute a number (base) raised to a power which can be an integer, negative or zero with out including the math library. This is what I wrote thus far. Please...
|
by: asif929 |
last post by:
I have another program to write, i will appreciate if somebody can
help......prompts the user to enter positive integer, and then prints
out four triangles
For Example: If we enter 4 it should...
|
by: Jesika L |
last post by:
I need help with a program that have to calculate the area under two curves. If anyone gave me any tips for it I will appreciate....
|
by: twin2003 |
last post by:
need help with inventory part 5 here is what I have to do
Modify the Inventory Program by adding a button to the GUI that allows the user to move to the first item, the previous item, the next...
|
by: Apolakkiatis |
last post by:
I need help with this program i am making... it is a print screen application which takes pictures of what's going on by the sendkeys command and pressing Ctrl + Print Scr (I know kind of corny but...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |