answersLogoWhite

0


Best Answer

void strsectdel (char *str, size_t offs, size_t ndel)

{

size_t len= strlen (str);

if (offs>len) return;

if (ndel>len-offs) ndel= len-offs;

if (ndel==0) return;

memmove (str+offs, str+offs+ndel, ndel);

len -= ndel;

str [len]= '\0';

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: C program to delete n characters from a given position from a given string?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you delete the given string in java programming?

You usually do not need to delete a String, since when the program no longer refers to it, the garbage collector will clean it up.


How do you use MID function in qbasic?

...QBASIC program code... name$="Jack" startCharPos%=2 howManyChars%=2 PRINT MID$(name$,startCharPos%,howManyChars%) ...output... ac EXPLANATION The MID$() function allows you to select characters from out of a string. In the above case the string is,... name$="Jack" ...where... J= string position 1 a= string position 2 c= string position 3 k= string position 4 ...thus, if we select MID$(name$,2,2)... ...this code is actually saying...select from the name...the character which begins at position 2 = a/and, extract 2 characters going along from there... = ac.


How do you delete a single text on your iPhone?

to delete a single text withing a string of text messages click the "edit" button in the string and select and delete


How would you implement a substr function that extracts a sub string from a given string?

substr(string, position [, count]) It extract substring starting from start and going for count characters. If count is not specified, the string is clipped from the start till the end


How to write printf statement for read characters into array str until the letter p is encountered?

In pseudo-code: while ( not(end of string) and letter(string at position X) is not 'P' ){ add(array, newposition) = letter(string at position X); }


What elements are in string?

A string is an array of characters.


How do you Print all the first characters in the string in python programming?

Let's say your string is a variable called "string" To print out all the characters in order, you would do: for i in string: print(string[i]) If you wanted to print out characters up to a point (n = maximum characters): for i in range(n): print(string[i]) hope this helps!


Are spaces taken as single character in a string?

public class count { public static void main(String[] args) { String string = "1 2 3 4"; char[] array = string.toCharArray(); System.out.println("Number of characters in string: " + string.length()); System.out.println("Number of characters in array: " + array.length); } } Output: Number of characters in string: 7 Number of characters in array: 7 So yes, spaces are taken as single characters in a string.


How do you return part of a cell in Excel?

You can use the LEFT, MID, or RIGHTfunctions to return parts of a cell in Excel.LEFT(text,number_of_characters)text = the string or cell address that you wish to extract fromnumber_of_characters = the number of characters that you wish to extract starting from the left-most characterMID(text,start_position,number_of_characters)text = the string or cell address that you wish to extract fromstart_position = position in the string that you will begin extracting from (first position in the string is 1)number_of_characters = number of characters that you wish to extractLEFT(text,number_of_characters)text = the string or cell address that you wish to extract fromnumber_of_characters = number of characters that you wish to extract starting from the left-most character


Count characters in an input string using c sharp?

Console.WriteLine("Please input a string:"); string str = Console.ReadLine(); Console.WriteLine("Number of characters: " + str.Length);


How do you get value of a string in reverse order in c?

Assume C#, not C: Traditional way: public string Reverse(string s) { if (string.IsNullOrEmpty(s)) return s; // "" or null char[] characters = s.ToCharArray(); Array.Reverse(characters); return new string(characters); } or as an extension method: public static string Reverse(this string s) { if (s == "") return ""; char[] characters = s.ToCharArray(); Array.Reverse(characters); return new string(characters); } The differences of the 2 methods above is on the caller (how to use Reverse()), and they may co-exist: For example: string test = "abc"; string result1 = Reverse(test); // traditional way string result2 = test.Reverse(); // call the extension


What is in string?

A string is a collection of words or characters in '' or "" it is also a data type.