i was given a project on checking and marking c++ code but in c++ if u leave spaces in between them for example like "int a ;" it is still correct...so basically admin will create the answers into sal database so in the database it shows answer="int a;"after many researchs on spaces i learn more about trim,trimLeft,trimright,trimstart,and trimend...then Replace so basically trim helped me to remove all the extra white spaces and if user type="int a;" = correct ans but if user key extra spaces in between a & ; system will mark it as wrong because if user type "int a ;"="int a ;"but in my database shows"int a;" so unless i can remove all the space between a &; i will be wrong...i tried using "EndWith(";")" but if i do this i cant use the check ans=ansfor example--->if(Userans == Realans && Realans.EndsWith(";"))//this is my sample on testing the codevoid Button1_Click(object sender, EventArgs e) {string Userans;Userans = TextBox1.Text;int i=0;while(i<10){Userans = Userans.Replace(" ", " ");i++;}//Userans = Userans.Trim();//Userans = Userans.Remove(1, 1);//Userans = Userans.Substring(1);string Realans;Realans = getans();Realans = Realans.Trim();Response.Write(Realans.EndsWith(";"));
Label2.Text =Realans;Label3.Text =Userans;TextBox1.Text = Label3.Text;if(Userans == Realans && Realans.EndsWith(";"))
{ Label1.Text="Correct Answer!"; } else { Label1.Text="Wrong Answer!"; }
}i wonder if i am able to remove all the spaces at the end? or use what kind of string.. really dunno how to solve zzzz