answersLogoWhite

0


Best Answer

#include<stdio.h>

#include<string.h>

void main()

{

char m_str[100],m_word[100],rep[100];

char str1[100];

int i,j,f,k;

int len1,len2,len3;

printf("\n enter the main string:=\n");

gets(m_str);

len1=strlen(m_str);

printf("\n enter the word that you want to replace:=\n");

gets(m_word);

len2=strlen(m_word);

printf("\n enter the word of same length you want to replace with:=\n");

gets(rep);

len3=strlen(rep);

for(i=0;i<len1;)

{

f=0;

for(j=0;j<len2;)

{

if(m_str[i]!=m_word[j])

{

while(m_str[i]!=m_word[j])

i++;

while(j<len2)

j++;

}

if(m_str[i]==m_word[j])

{

f=1;

j++;

i++;

}

}

if(f==1)

{

for(k=0,j=i-len2;k<len3;k++)

m_str[j+k]=rep[k];

}

}

printf("\nthe replaced string is :-");

puts(m_str);

}

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

14y ago

this program waste program ra chantiga, dont waste ur time

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a 'c' program using command line arguments to search for a word in a file and replace it with the specified word?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Develop a program that reads a floating point number and then replace the right most digit of the integral part of the number?

/* program without if statement */ #include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main() { int a,c; float b; clrscr(); printf("Enter the value \n"); scanf("%f",&amp;b); a=c; c=a%10; printf("the right most digit is %d",c); getch(); }


How do I write a batch file to search recursive folders for a list of partial file names with wildcards and then delete the files?

No need for a batch file, the following commands will do it: CD folder FOR /F %i IN (files.txt) DO DEL %i /P /F /S The CD command sets the current folder. All deletions will occur in the specified folder and its sub-folders. The files.txt file must be a list of file names (wildcards permitted) with one file name per line. If this file does not reside in the current folder you must specify the fully-qualified path or the relative path (relative to the current folder). The FOR loop essentially executes the DEL command for each file in files.txt. The DEL command line switches are: /P (prompt for confirmation before deleting each file) /F (force delete read-only files) /S (recurse through sub-folders of the current folder). To suppress prompting, remove /P but add /Q (quiet mode) to suppress prompting on global wildcards. For more help on this, enter DEL /? at the command prompt. For more help on the FOr command, type FOR /? at the command prompt. If used in a command script (.cmd) or batch file (.bat), replace %i with %%i. The only real advantage of using a batch file (other than to save a bit of typing) is that you can also pass the root folder and the file containing your file list as parameters (identified by %1, %2, etc).


Write a c program using string concept enter a sting and replace the new string in to old string and find no of occurrence?

print c co com comp compu


What is function in a C program?

Every program has to have at least one function to define the entry point of the application. In C, we call this the main function and it has two possible prototypes: int main (void); int main (int argc, char* argv[] ); The arguments to main are parameters that we can pass from the command line when we execute the program. The first prototype has no arguments (void means no type) and is used in programs that do not require any command line parameters. The second is for those that do. The first argument, argc, tells us the number of arguments that were passed from the command line while the second refers to a null-terminated array of null-terminated character arrays (strings) containing those arguments. The count is always at least 1 because the first argument (argv[0]) always refers to the command itself (e.g., the full path and file name of the executable). argv[argc] is always a null-terminator, thus argv[1] through argv[argc-1] refer to the individual arguments. The purpose of the main function is to process the command line arguments (if any) and coordinate the program's execution. When execution has completed, the main function returns a value to the hosting environment. Typically we return 0 to indicate the program executed successfully (no error) and any non-zero value to indicate some user-defined error level. Although we can write an entire program using just the main function alone, non-trivial applications have to make use of functions otherwise we'd end up writing extremely low-level code that is only slightly more abstract than assembly language. Without functions, code would be highly repetitive, tedious to write, prone to error and difficult to maintain. To reduce the tediousness of code repetition, code that is invoked more than once (outside of a looping structure) can be separated out to create a function with a user-defined name. We use the name to call the function. Functions can also be generalised to accept arguments thus we don't have to write separate functions for code that only differs by which variables it operates upon, we can simply pass those variables to one copy of function. Be eliminating the need for duplicate code, we greatly reduce the cost of maintenance; if we need to modify the code in any way we only need to make the change in one place. In C we use a bottom-up approach to function design. First we define our low-level functions and then we use these functions as the building blocks for more complex, higher-level functions. In this way, our main function becomes the highest level function. High-level functions are an abstraction; they allow us to name a block of code such that the name closely reflects the purpose of the code. In this way, we do not have to examine every line of code in order to understand the program; knowing what a function does is usually more important than how it does it. Thus our code becomes easier to read. Code that is easy to read is also easy to maintain. When we invoke a function, execution automatically returns to the calling code when the function ends. Functions can also return a value to their callers. A function can therefore be thought of as being a miniature program in its own right. Functions tend to contain very little code. Some will only have one line of code. Many of these are used purely to invoke a more complex line of code, thus making code easier to write. However, as a general rule, we try to keep functions small enough so that we can see the entire function without having to scroll. We can achieve this very easily by refactoring complex code as a function. Although there is a performance penalty in invoking (and returning from) functions, by keeping functions as simple as possible we can take advantage of inline expansion. That is, the compiler can replace function calls with the function's actual code, substituting its formal argument names for the actual arguments. This naturally creates duplicate code, however duplicate code is only a "bad thing" when we write it ourselves, because we are then forced to maintain all instances of it. Enlisting the compiler to generate duplicate code for us means we gain the advantage of faster execution without the added cost to maintenance. Of course, inline expansion also results in larger code and that can have an impact upon performance as well, however the compiler has built-in optimisers that can determine when inline expansion is appropriate. The call and return mechanism itself is relatively simple. It is achieved through the use of an area of memory known as the call stack. Every thread of a process has its own dedicated stack, thus there is no problem when two threads concurrently invoke the same function. The call stack is allocated when a thread is invoked and remains in memory until the thread terminates. Thus there is no cost involved in using the stack, we simply need to keep track of the top of the stack, which is achieved through a (hidden) pointer. When we invoke a function, we need to know the address of the function. The compiler can determine the address from the function's name alone, however we can also use function pointers to invoke a function (function pointers allow us to pass functions to functions). Before we pass control to a function address, we must push the return address onto the stack. The return address is the address of the next machine code instruction that follows the function call. Again, the compiler can determine that address for us. When we pass control to the function address, the body of the function executes. When it is ready to return to its caller, the return address is simply popped from the stack and control returned to that address. This mechanism means that functions can call functions without losing track of where calls came from, much like a breadcrumb trail. The call stack is also used to pass arguments to functions. The arguments passed to a function are called the actual arguments while the arguments used by a function are the formal arguments. All arguments are passed by value in C and this is achieved by pushing those values onto the stack. When the function gains control, those values are assigned to its appropriate formal arguments. The stack is also used to allocate the function's non-static local arguments (automatic variables). Remember that no allocation actually takes place when we push values onto the stack, all we really do is assign values to the address pointed to by the stack pointer and then increment it accordingly. To release the memory, we simply decrement the pointer. When a function returns a value, that value is temporary. If we do not assign the value to a variable upon returning from a function, the value is lost. In addition, all automatic variables fall from scope when a function returns, thus we cannot return a reference to a local variable. The value may very well be available on the stack beyond the stack pointer, however that memory can no longer be regarded as being valid; it may be overwritten at any time. Thus all return values must be returned by value. If we need a value to persist beyond the scope of the function, it must be allocated on the free store rather than the call stack. We can then return a pointer (by value) to that allocation.


List three situations in which you might want to create a restore point?

1. Before you make major chages 2. Before you install a new program (incase it doesn't run, that way u can go back to the way the coputer was be for program was installed) 3. Before you replace a old program with a new one (the new one may not work as well as the old one)

Related questions

When deleting text with the Replace command which text box should be blank?

The lower text box should be blank. In the top one you would have the content you want to replace. By having nothing in the bottom one, then the specified content will be replaced by nothing, in effect deleting the specified content.


How do you use the replace command?

'replace' is not a standard Unix command. There is a replace command in mySql, but I don't know if this is the one you are referring to.


Does the to find command allow you to replace a word or phase in the find what box with another word or phase you key in the replace with box?

No. You would use the replace command for that. The find command only allows you to find a word; find and replace will do both.


Which program is meant to replace SSH?

There is no particular program meant to replace SSH. SSH is considered a modern and secure program, so there is no reason to replace it.


Which command do you use to locate and select all instances of a word?

Use "Find" to locate all instances of a word.


Should insurance replace all cabinets after water damage?

Replace or repair all damaged as specified in your policy.


What is the difference between replace and a replace all command technically?

Replace will replace one instance of what you want to replace. Replace All will replace all instances of what you want to replace.


Which program did the Supplemental Nutrition Assistance Program replace?

food stamp program


What does the replace command perform in SQL?

The replace command function in SQL preforms comparisons on the collation of an input or inputs. It also replaces the text in a string of the SQL server.


Is this statement true or false Word's find and replace feature will locate each occurrence of a specified word or phrase and then replace it with specified text?

It can do that. It depends on how you use it. If you choose the Replace All feature, it will replace every occurrence with what you have chosen, You can also replace things on a one by one basis. You can also choose to replace some and not replace others.


How do you get a command block?

Command block id: 138Type these in commands and replace with your username:/give 138(v1.7.9-) OR/give command_block


What is the difference between warranty and guaranty?

Warranty- Promising to repair or replace it if necessary within a specified period of time Guarantee- A promise that a product will be repaired if not of a specified quality. Its not a big difference.