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
Which text features does this section contain? Check all that apply.
NISA [10]

which ones apply manuelh


6 0
3 years ago
You are building a network and need to connect five computers in an office. They will be on the same network segment and you sho
lilavasa [31]

Answer:

a lan party

Explanation:

because it's your personal party

4 0
3 years ago
Character literals are enclosed in ________; string literals are enclosed in ________. Group of answer choices double quotes; do
adelina 88 [10]

Answer:

Single quotes; Double quotes

Explanation:

Character literals is a type of literal in Java programming used for denoting constant valued character. Examples are 'g', '6', 'A' '+' etc.

String literals is a type of literal in Java programming used for representing or displaying of a sequence of characters or string values. Examples are "Hello Brainly user"

In Java programming, Character literals are enclosed in single quotes, string literals are enclosed in double quotes.

7 0
3 years ago
Low-level formatting ____. Group of answer choices is different from physical formatting is usually performed by the purchaser o
Drupady [299]

Low-Level formatting is usually performed by the purchaser of the disk.

<h3>What is low-level formatting?</h3>

Low-Level formatting can be defined as is performed at the factory which electronically creates the hard drive tracks and sectors and tests for bad spots on a disk surface.

Low-level formatting is usually performed by the purchaser of the disk device.

Therefore, B is the correct option.

Learn more about Low-level formatting here:

brainly.com/question/13797778

#SPJ1

3 0
2 years ago
WILL GIVE BRAINLIEST!!!!!!!
lisov135 [29]

Answer:

Ac

Explanation:

Ac maybe.Idk sorry.

8 0
3 years ago
Other questions:
  • Interpretations of​ Moore's law assert​ that:
    13·1 answer
  • Problem 2 (40 points)-Write a program. Submit a file named weight.cpp Create a program that continuously allows a user to enter
    5·1 answer
  • Storing a value in a variable<br> Exponent<br> Variable<br> Assignment<br> Operator
    13·1 answer
  • What weight pencil is recommended for darkening lines and for lettering? *
    7·2 answers
  • What are the features of the Outline view in Word? Select three options.
    12·2 answers
  • Pls help me
    5·1 answer
  • HIPAA requires the following controls for medical records: A. Encryption of all data B. Technical safeguards C. Physical control
    12·1 answer
  • Which sentence(s) below are true?a. IP stands for Internet Protocol.b. In most home networks IP addresses are assigned by the In
    6·1 answer
  • (b) Cell B12 contains the formula, ROUND((SUM(B5:B9)*D1),1).
    15·1 answer
  • If a TextView has not been displayed yet, it is possible to retrieve measurements about its width and height using the _________
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!