+ 2

My code for pig latin works for only single words,can anybody help me how it can be modified to work for sentences

#include <stdio.h> int main() { char word[100]; int i; printf("enter the word\n"); scanf("%s",&word); i=0; while(word[i]!='\0') { i++; } word[i]=word[0]; word[i+1]='a'; word[i+2]='y'; word[i+3]='\0'; word[0]=' '; printf("after changing to pig latin\n"); printf("%s",word); }

13th Jan 2020, 10:50 AM
Jaswanth Kishore S
4 ответов
+ 1
Here is java implementation import java.*; import java.util.Scanner; class PigLatin { public static void main(String arg[]) { Scanner sc=new Scanner(System.in); String accept=sc.next(); StringBuilder sb=new StringBuilder(accept); char copy=sb.charAt(0); //System.out.println(copy); StringBuilder delete=sb.deleteCharAt(0); System.out.println(delete); System.out.println(sb.append(copy)+"ay"); } }
21st Jan 2020, 7:08 AM
kartik narang
kartik narang - avatar
0
%[^\n] can be used to read till end but with above code won't that just change the last or first word into pig latin n not the others
13th Jan 2020, 12:16 PM
Jaswanth Kishore S
0
And coder kitten thanks But I'm just a beginner n i didn't understand what u said
13th Jan 2020, 12:16 PM
Jaswanth Kishore S
0
Ok got it but again i dont actually know how to use strtok
13th Jan 2020, 12:42 PM
Jaswanth Kishore S