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
Darina [25.2K]
3 years ago
8

In C, how could I use a command line input to remove certain characters from an existing string? For example, if I have string '

OXOXO' and whenever the character 'N' is put into the command line, a character from the existing string would be removed. So if the user inputs the string 'oNoN' into the command line, the new string would be 'OXO'.

Computers and Technology
1 answer:
s344n2d4d5 [400]3 years ago
6 0

Answer:

// here is code in C.

#include <stdio.h>

// main function which take input from command line

int main(int argc, char** argv) {

               // variables

               int char_count = 0, i=0;

               // string as char array

               char inp_str[100] = "OXOXO";

               //count  total number of 'N's in command line argument

               while(argv[1][i++] != '\0')

               {

                 if(argv[1][i]=='N')

                     char_count++;

               }

               // find the length string

               int l = 0;

               while(inp_str[l] != '\0')

                               l++;

               //reduce length of the string

               l = l - char_count;

               //set null char at index "l" so it will  removes character after index "l"

               inp_str[l] = '\0';

               printf("%s\n", inp_str);

               return 0;

}

Explanation:

Create a string as character array and initialize it with "OXOXO".After that count the number of "N" which come from the command line argument.Then find the length of input string.Reduce the length of string and set "null" at index "l" in the string.Then print the string.

Output:

OXO

<u>Command line argument:</u>

You might be interested in
Using computers can lead to a number of physical safety issues. State and explain TWO(2) of these types of issues.​​​​​
Ira Lisetskai [31]

The types of issues that is seen are:

  • Electrocution
  • Fire
  • Tripping over wires and others.

<h3>What is the physical safety about?</h3>

There are a lot of of physical safety issues that can come up from using ICT devices.

A fire outbreak can occur if there is an issue with the wiring of the computer system or when there is too much voltage supplied and this is therefore a type of physical safety issues in the computer room.

Note that Electrocution is said to be the death or bad injury that is known to be caused as a result of an electric shock from electric current that tends to pass through the body.

Hence, The types of issues that is seen are:

  • Electrocution
  • Fire
  • Tripping over wires and others.

Learn more about Electrocution from

brainly.com/question/1810934

#SPJ1

6 0
2 years ago
Characteristics of VR headsets​
weeeeeb [17]
Answer Believable Virtual Word. The believable virtual world is a key characteristic of Virtual Reality. ...
Immersive. ...
Feedback. ...
Interactive. ...
Virtual Reality Headset. ...
Computing Device (Commuter / Smart Phone) ...
Virtual Reality Input and Output Devices. ...
Fully Immersive Virtual Reality.
5 0
3 years ago
1. Write a statement that opens the file Customers.dat as a random access file for both reading and writing.
KengaRu [80]

Answer:

Explanation:

In Python you need to give access to a file by opening it. You can do it by using the open() function. Open returns a file object, which has methods and attributes for getting information about and manipulating the opened file.

https://eecs.wsu.edu/~cs150/tutorial/file/code11_3.html

Look at this link it may help.

3 0
3 years ago
A _____ is a tool that helps you research information on the Internet.
never [62]

a search engine is a tool that helps you reaserch information on the internet, because it is what you use to type in the info you want to learn more about

6 0
4 years ago
It is very easy to change data into charts<br> what is a Microsoft Excel Microsoft Outlook or both​
Vadim26 [7]
It’s microsoft Excel
8 0
3 years ago
Other questions:
  • The         provides access to the Internet; may also be internal
    5·1 answer
  • When u look at a green object through red glass the object will appear
    11·2 answers
  • Double clicking a word selects the entire word?
    10·1 answer
  • Which type of natural hazard is sometimes caused by human activity?
    6·1 answer
  • Write a program that asks the user to enter the size of a triangle (an integer from 1 to 50). Display the triangle by writing li
    15·1 answer
  • How should you best communicate<br> this information to Keisha?<br> (Select all that apply.)
    13·1 answer
  • Write a python program to find factorial, use exception handling and display an appropriate message if the user inputs alphabets
    7·1 answer
  • Order the steps for accessing the junk email options in Outlook 2016
    9·2 answers
  • Write an algorithm to calculate the average<br> value of array of integer elements
    13·1 answer
  • During the POST process, the BIOS uses two (2) different ways to notify you of a problem, Error beep codes and error messages, e
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!