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 1388 Laharl 849
Recognized Expert Contributor
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, but not
familiar with C code it would take me some time to get it to work. A
good C programmer can probably give me the code in a few minutes.
Here's the program specs:
I'm doing a study on the italicized words in the King James Bible. The...
|
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 found it the other
day and decided to fix it up. I have one problem that I can't figure
out in it still. When I run the program it prompts for the option
number as it is supposed to, but when I enter in the number it outputs
that I have entered an...
|
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 occurs. After the
program has read the file, it should offer a menu with three choices.
the first is to list all the words along with the number of occurences.
The second is to let you enter a word, with the program reporting how
many times the...
|
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 help me.
#include <iostream>
using namespace std;
int main()
{
double x, y;
cout << "Enter a base number: ";
|
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 shows
*
* *
* * *
* * * *
| |
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 item, and the last item in the inventory. If the first item is displayed and the user clicks on the Previous button, the last item should display. If the last item is displayed and the user clicks on the Next button, the first item
should display. the...
|
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 w/e). I use VB08 and need help on how i would be able to "paste" these onto another form of my application... then be able to look through the pictures from the first to the last.
Help Please...!
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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 we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |