#include <stdio.h>
#include <string.h>
main()
{
char str[124],str_cpy[124];
char wrd[24];
void *ret;
int i,j,cnt_str,cnt_wrd,cnt_cpy,res = 0;
printf("Enter the string: ");
ret = gets(str);
printf("Enter word to remove: ");
ret = gets(wrd);
top:
cnt_str = strlen(str);
cnt_wrd = strlen(wrd);
ret = strstr(str,wrd);
if(ret != NULL)
{
cnt_cpy = (unsigned int)ret -(unsigned int)str;
strncpy(str_cpy,str,cnt_cpy);
str_cpy[cnt_cpy - 1] = '\0';
strncat(str_cpy, (ret + cnt_wrd),(cnt_str - cnt_wrd));
strcpy(str, str_cpy);
res++;
}
else if(res == 0) printf("Word not found\n");
else goto last;
goto top;
last:
printf("New string: %s\n",str);
}
what is if(!(str[i]==32))
program to extract a given word from a file
class LongestWord{String str = "Ram is intelligent boy";String stringArray[] = str.split("\\s");public String compare(String st1, String st2){if(st1.length()>st2.length()){return st1;}else{return st2;}}LongestWord(){String word = "";for(int i=0;i
import java.util.Scanner; public class Palindrome{ public static void main(String[] args){ String front; String back =""; char[] failure; String backwards; Scanner input=new Scanner(System.in); System.out.print("Enter a word: "); front=input.next(); front=front.replaceAll(" ", ""); failure=front.toCharArray(); for (int i=0; i<failure.length; i++){ back=failure[i] + back; } if (front.equals(back)){ System.out.print("That word is a palindrome"); }else System.out.print("That word is not a palindrome"); }}
You can have two String variables (note that String variables are object references) refer to the same String object like so: String str1 = "Hello"; String str2 = str1; Now the str1 and str2 are references for the same String object containing the word "Hello". If you actually want a new String object with a copy of the contents of the original String, you use the String constructor that takes a String argument, like so: String str3 = new String(str1); Now str1 and str3 refer to SEPARATE String objects that happen to contain the same sequence of characters (the word "Hello"). Since Strings objects in Java are immutable, they can be shared without worrying about the contents used by one variable being upset by the use through another variable as might happen with char[] arrays in C or C++ so the first method is probably sufficient for most cases.
what is if(!(str[i]==32))
what is if(!(str[i]==32))
You can do this: <?php if ( $word === strrev( $word ) ) { echo "The word is a palindrome"; } else { echo "The word is not a palindrome"; }
Check the documentation of the String class, for a method that searches for a substring.
#include<stdio.h> void main() { int cnt=0,i; char str[100]; printf("Enter the string "); scanf("%s",str); for(i=0;i<strlen(str)-1;i++) { if(str[i]==' ') cnt++; } printf("\nTotal no. of word in string = %d",cnt); }
You would use the ToUpper and ToLower functions. string name = "XVengeance"; string upperName = name.ToUpper(); string lowerName = name.ToLower(); Console.WriteLine(upperName); Console.WriteLine(lowerName); Console.ReadLine(); I don't think I'm supposed to do your homework for you, but this code should get you started on making a more dynamic program.
Write a program for this process.
program to extract a given word from a file
It is a simple program. i think u may understand it :#include#include#includevoid main(){char s[10]=answers.com;char x[10];int a;clrscr();strcpy(x,s);strrev(s);a=strcmp(s,x);if(a==0){printf("the entered string is palindrome");}else{printf("the entered string is not palindrome");}output:given string is not palindrome
class LongestWord{String str = "Ram is intelligent boy";String stringArray[] = str.split("\\s");public String compare(String st1, String st2){if(st1.length()>st2.length()){return st1;}else{return st2;}}LongestWord(){String word = "";for(int i=0;i
String him along is a saying. It begins with the word string.
The most common is Microsoft Word