1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Rina8888 [55]
3 years ago
15

You will read in two strings from a file cp4in_1. Txt at a time (there will be 2n strings, and you will read them until EOF) and

then do the following. You alternately take characters from the two strings and string them together and create a new string which you will store in a new string variable. You may assume that each string is no more than 20 characters long (not including the null terminator), but can be far less. You must use pointers. You may store each string in an array, but are not allowed to treat the string as a character array in the sense that you may not have statements like c[i]
Computers and Technology
1 answer:
Novosadov [1.4K]3 years ago
5 0

In this exercise we have to use the knowledge in computational language in C++ to write the following code:

We have the code can be found in the attached image.

So in an easier way we have that the code is:

<em>#include <stdio.h></em>

<em>#include <studlib.h></em>

<em>int main() </em>

<em>{</em>

<em> File*fp;</em>

<em>fp=fopen("cp4in_1.txt","r");</em>

<em>char ch;</em>

<em>//while(1)</em>

<em>//{</em>

<em>while(!feof(fp))</em>

<em>{</em>

<em>char *s1,*s2,*s3;</em>

<em>s1 = (char*)malloc (20 *sizeof (char));</em>

<em>s2 = (char*)malloc (20 *sizeof (char));</em>

<em>s3 = (char*)malloc (20 *sizeof (char));</em>

<em>int i=0,j=0,x,y;</em>

<em>while(1)</em>

<em>{</em>

<em>ch=getc(fp);</em>

<em>if(ch=='\n')</em>

<em>break;</em>

<em>*(s1+i)=ch;</em>

<em>i++;</em>

<em>}</em>

<em>while(1)</em>

<em>{</em>

<em>ch=getc(fp);</em>

<em>if(ch=='\n')</em>

<em>break;</em>

<em>*(s2+j)=ch;</em>

<em>j++;</em>

<em>}</em>

<em>for(x=0;x<i;x++)</em>

<em>{</em>

<em>*(s3+x)=*(s1+x);</em>

<em>}</em>

<em>for(y=0;y<j;x++,y++)</em>

<em>{</em>

<em>*(s3+x)=*(s2+y);</em>

<em>}</em>

<em>for(x=0;x<i+j;x++)</em>

<em>{</em>

<em>printf("%c",*(s3+x));</em>

<em>}</em>

<em>printf("\n");</em>

<em>getc(fp);</em>

<em>}</em>

<em>}</em>

See more about C++ code at brainly.com/question/19705654

You might be interested in
Teknoloji ile ilgili 5 tane örnek yazabilir misiniz? Lütfen..
kiruha [24]

Answer:

אז מה עוד אני יכול להגיד לך בסדר אני חולה

6 0
3 years ago
The hardware components of a computer system interact with each other by using which of the following?
Inga [223]
B it is b..............................................
6 0
4 years ago
Read 2 more answers
How do spear phishing attacks differ from standard phishing attacks?
mina [271]

Answer:

Phishing attacks normally target random people on mass amount by sending emails to users. In the other hand the spear phishing only targets 1 person hence the name "spear".

Hope this help please give the brainliest award.

5 0
3 years ago
Which type of input peripheral is most prevalent in a Point of Sale system?A. External USB storage.
Darina [25.2K]

Answer:

B. Card reader.

Explanation:

Peripheral devices are generally auxiliary devices such as mouse, keyboard, card reader, pen drives, microphones, graphics cards, etc. that are connected with the computer are work in some way with it. In Point of sale (POS) devices card reader are used to read debit or credit cards.

4 0
3 years ago
Read 2 more answers
When do programmers use If conditional statements? when they want a certain event to occur when a condition is met when they wan
lyudmila [28]

Answer:

when they want a certain event to occur when a condition is met

Explanation:

5 0
3 years ago
Read 2 more answers
Other questions:
  • What does a contain after the following code runs?int[] a = {1, 3, 7, 0, 0, 0};int size = 3, capacity = 6, value = 5;int pos = 0
    10·1 answer
  • You are performing a manual WLAN RF site survey in a location that has several long hallways with small offices on both sides. Y
    8·1 answer
  • To find and engage in Twitter conversations happening in specific geographical areas that are relevant to your company, you shou
    6·1 answer
  • You have a desktop computer that supports both IEEE 1394 and USB 2.0. You are purchasing some devices that will connect to these
    13·1 answer
  • Which of the following is a difference between a centralized communication network and a decentralized communication network? a.
    15·1 answer
  • In electrical work, resistance is often represented by thea. Greek symbol O.
    12·1 answer
  • What are Manuscript signs​
    8·1 answer
  • Please help me with this this is Computer chapter Advanced HTML of class 8th​
    10·1 answer
  • You are a knowledge engineer and have been assigned the task of developing a knowledge base for an expert system to advise on mo
    14·1 answer
  • Select the correct answer from the drop-down menu.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!