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
A(n) _____ is a fake online persona created to promote a particular point of view, often in praise of a firm, product, or indivi
drek231 [11]

Answer:

<u>Sock puppet</u>

Explanation:

A sock puppet, a reference to a puppet created by placing a sock over one's hand, is a misleading or fake online identity created to promote a particular point of view, often in praise of a firm, organization, product, or individual; to manipulate public opinion or to argue, bully or review products. Regardless of the purpose it was created for, sock puppets are rarely welcome in online communities and forums.

4 0
3 years ago
This is using python.
Wittaler [7]

Answer:

discriminant = b * b - 4 * a * c

discriminant = b ** 2 - 4 * a * c

Explanation:

The operands are correct and in the right order (for python).

** is the operand for squaring something.

* is the operand for multiplying something.

- is the operand for subtracting something.

8 0
2 years ago
Read 2 more answers
What is the relation between Information and Data?
Rudiy27

Answer:

In a sentence: data is raw numbers, while information is organized data.

Explanation:

Data is a series of numbers or facts.  A data set is a collection of data that are related (for examples all the students result in your last math exam).  But it's not organized by itself... and rarely mean anything when looked at it in a raw manner.

To make sense of a data collection, you have to analyze it, calculate the mean or median of the data set for example... this is a treatment that has to be done to a data set to give it significance.. after such analysis, the result you have (mean, median, etc..) is a piece of information devired from the data.

3 0
3 years ago
3.4 lesson practice quiz edhesive
Marina86 [1]

3.4 lesson practice quiz edhesive :

Write a program to check if user inputs "yellow"

Answer:

In Python:

col = input("Enter Color: ")

if col == "yellow":

   print("True")

else:

   print("False")

Explanation:

This prompts the user for color

col = input("Enter Color: ")

This checks if color is yellow

if col == "yellow":

If true, this prints true

   print("True")

If otherwise, this prints false

else:

   print("False")

5 0
2 years ago
1. Answer the following questions: a. What are the different types of number system? Name them.​
BigorU [14]

Answer:

binary,decimal, hexadecimal and octal number system

5 0
2 years ago
Other questions:
  • Given the integer variables x and y, write a fragment of code that assigns the larger of x and y to another integer variable max
    5·1 answer
  • Which code fragment constructs an arrray list named players that is initialized to contain the strings "player 1" and "player 2"
    15·1 answer
  • To access WordPad, Jill will click on Start, All Programs, Accessories, and WordPad. To access Notepad, Karl will click on Start
    5·1 answer
  • Which of the following is used by credit card companies to determine APR?
    10·2 answers
  • Working together, printer A and printer B would finish the task in 24 minutes. Printer A alone would finish the task in 60 minut
    8·1 answer
  • The simplest method to copy information is to first select the information you want to copy, and then use the Copy button and th
    11·1 answer
  • Is it possible to make teleportation with a fusion device
    15·1 answer
  • Which type of network involves buildings in multiple cities connecting to each other?
    8·1 answer
  • How would a barcode reader be used in a healthcare industry?​
    6·1 answer
  • Briefly describe the working of computer processing system?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!