0

there's an error in this codes, can you help me fo fix it

19th Dec 2020, 9:27 PM
Princess Manalo
2 Antworten
+ 1
First there have to be copied l characrers. Second if starts with i = 30 then cannot come into the loop if a input string will be shorter then 30 etc. Right code as follows: i=0; while(i<l) { string tmp=str1[i].ToString(); str2[i] = tmp; i++; }
19th Dec 2020, 10:08 PM
JaScript
JaScript - avatar
0
string str1; int i,l; Console.Write("Input the string : This is a string to be copied "); str1 = Console.ReadLine(); l=str1.Length; string[] str2=new string[l]; i=30; while(i<l) { string tmp=str1[i].ToString(); str2[i] = tmp; i++; } Console.Write("\nThe First string is : {0}\n", str1 ); Console.Write("The Second string is : {0}\n", string.Join("",str2)); Console.Write("Number of characters copied : {0}\n\n", ++i);
19th Dec 2020, 9:27 PM
Princess Manalo