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
Python;
riadik2000 [5.3K]

a = int(input("Class A tickets sold: "))

b = int(input("Class B tickets sold: "))

c = int(input("Class C tickets sold: "))

print("Total income generated: $"+str((a*20)+(b*15)+(c*10)))

I hope this helps!

4 0
3 years ago
Look at the picture lol
andrey2020 [161]

Answer:

Zoom in more please and than i can help

Explanation:

6 0
3 years ago
Read 2 more answers
Renee just got on the freeway to go to her cousin's house in Denver. She is driving 50 miles per hour. Her sister Kim left one h
defon

let's say they catch-up to each other after t hour.

so

in t hour distance travelled by Renee

d = speed × time = 50t

in t hour distance travelled by Kim

d = speed × time = 60(t-1) + 0×1 = 60(t-1)

Note: here kim didn't covered any distance in first hour and in rest t-1 hour it travelled all distance

now.as distance travelled by both is same so

60(t-1) = 50t

60t -60 = 50t

adding 60 both sides

60t = 50t+60

subtracting 50t both sides

60t -50t = 50t+60 - 50t

10t = 60

dividing by 10 both sides

t = 60/10 = 6

so in 6 hour both will catch-up to each other

3 0
3 years ago
Which of the following is a unique feature of credit unions?
Alecsey [184]

A list of multiple answers is provided;

 

<span>a)      </span>Credit unions are typically owned and run by their members

<span>b)      </span>Credit unions limit membership to certain people or groups

<span>c)       </span>Credit unions offer a wide variety of banking services

<span>d)      </span>Both A & B

 

The answer is both (D) Both A & B

 

As compared to banks, credit unions are small in size and are created, owned and operated by their members or participants. They are non-for-profit financial cooperatives and are structured to serve a particular region. Thus, membership in majority of credit unions is that you have to live in the area. You may also be able to join based on other various factors like Employer and family.

6 0
3 years ago
In computer Drag and Drop“ means to select the items, hold down the mouse and
kompoz [17]

Answer:

Release the mouse in the desired location.

5 0
3 years ago
Other questions:
  • Technician A says that OBDI and OBDII use different DLC connectors. Technician B says that OBDII standardizes the designations f
    13·1 answer
  • A network ____ usually contains a computer, networked peripheral, or network device.
    14·1 answer
  • To have the most impact when using email, you should structure your messages so that
    5·1 answer
  • 2.7 code practice question 1 edhesive
    13·2 answers
  • Which command will display each line in the text file based on the alphabet?
    10·1 answer
  • When you take action independent of direct instruction, you are showing _____.
    11·1 answer
  • What is the correct way to write h1 tag
    12·1 answer
  • What is a field on a table
    13·1 answer
  • If you have questions about taxes, where can you go to get answers?
    14·1 answer
  • Can someone pls do a toradora,Mha or princess jellyfish rp I'm open for anyother rp's
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!