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
In 1-2 pages, identify a social networking technology and identify at least 10 security and/or privacy risks the technology has
algol13

Answer:

One of the biggest social media giants has faced many such security and privacy risks in the past 3 years. 10 are listed below:

1. No one can forget the New Zealand attack on the mosque, and it was telecast live via it. And that is certainly a security risk. And if someone is able to stream live, the AI is in question definitely as this cannot be telecast.

2. Can you forget the various US shooting cases in the past 5 years? And many out of them where telecast lives on it. Again the AI, and the authentication is in question.

3. Many evils have many times advertised itself through it, and that is a security risk. This put up the question on the Data Scientists of the company.

4. It's a huge data on it, and many users have been able to misuse it, and that is a security risk. This put up the question mark on the application of the Big Data.

5. Once, the UK parliament questioned it to sell the secret data, and that was a privacy risk.

6. An Engineer was caught negotiating to sell secret users data to a third party, and that is a privacy risk as well as a question on management technology, as its possible now to check these kind of frauds.

7. Its accounts have been hacked many times, as well as millions of user-profiles, were stolen. This is a security and privacy risk.

8. Its data is still not safe as evils have proved they can break the authentication. However, it has reacted well, and they look like being a safe destination now.

9. Once, someone from Russia was caught collecting a lot of data from it. That was a security and privacy risk. And surely if someone is uploading a lot of complicated and confidential data, must be checked through proper AI implementation.

10. In India too there have been claims that a lot of personal information during elections 2014 was sold. That was a security and data risk. And the data scientists were proved vulnerable again. Its quite sure hence, a lot of work has to be done in Data Science and Artificial intelligence still.

However, its owner is one of the finest souls on earth. He donated all his money when he was blessed with a child. Some out of his team cheated, and else some technology failure or the huge amount of data was the reason for the fault. However, other companies are also facing such problems. And hence, he cannot be blamed for this. And the company now definitely has recovered from the nightmare that they faced in the past 3 years.

Explanation:

The answer is self explanatory.

8 0
3 years ago
PLZZZ HELP!!!
kifflom [539]

Answer:

D the answer is D or c one of those 2

3 0
3 years ago
What are general purpose computer and special purpose computer?​
icang [17]

Answer:

General purpose computers are designed to be able to perform variety of tasks when loaded with appropriate programs, while special purpose computers are designed to accomplish a single task.

3 0
3 years ago
Read 2 more answers
What does it mean to have liability for a company?
astraxan [27]

you can get tax identification number, open a bank account and do business all under its own name


3 0
3 years ago
Identify a statement that accurately differentiates between short-term memory and working memory.
Veronika [31]

Answer:

Short term memory is in which a person may forgot very previously introduced knowledge, whereas working memory...well...works. Most people have working memory.

Explanation:

5 0
3 years ago
Other questions:
  • When you make a pointer variable im C++, is star label a must?
    9·1 answer
  • A user has been given Full Control permission to a shared folder. The user has been given Modify permission at the NTFS level to
    11·1 answer
  • What are the three business writing formats
    12·1 answer
  • Write a program whose input is two integers and whose output is the two integers swapped. Ex: If the input is: 3 8 then the outp
    12·1 answer
  • Which elements are in the Sort dialog box? Check all that apply.
    9·1 answer
  • Both the Alphabetic Index and the Tabular List must be used to locate and assign a diagnosis code in ICD-10-CM. Group of answer
    7·1 answer
  • Running away from home
    11·2 answers
  • Vẽ sơ đồ DFD cho của hàng bán điện thoại ( Môn phân tích và thiết kế hệ thống thông tin)
    10·1 answer
  • 2. What is MOST TRUE of a mature technology?
    7·1 answer
  • question 2 which data link layer protocol defines the process by which lan devices interface with upper network layer protocols?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!