简体   繁体   English

按空格读取拆分输入,用户在文本字段中输入

[英]read split input by space enter by user in textfield

I need to create a program that is able to detect syntax error in C language programming. 我需要创建一个程序,该程序能够检测C语言编程中的语法错误。 Let's say the grammar should be 假设语法应该是

printf("statement");

How could I create an interface that is able to detect if there's any error in the coding? 如何创建一个能够检测编码中是否有错误的接口? The output should be "Syntax error!Please try again" or "Well done!No syntax error" 输出应为“语法错误!请重试”或“做得好!无语法错误”

My teacher advice me to use stringtokenizer . 我的老师建议我使用stringtokenizer Can anyone help me with this? 谁能帮我这个? I dont mind if the user need to space for each input such as: 我不介意用户是否需要为每个输入留出空间,例如:

**printf** (space) **("** (space) **statement** (space) **")** (space) **;**

Yes. 是。 the tokenizer function [in c ] you are looking for is strtok_r() . 您要查找的tokenizer函数[在c ]是strtok_r() Please check the details regarding the usage of this function in the man page here . 请在此处的手册页中查看有关此功能用法的详细信息。

However, this is going to be a tricky job. 但是,这将是一项棘手的工作。 Best of luck with your efforts. 祝您好运。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 等待用户输入的 TextField - TextField waiting for a user input 在ButtonClick或Enter键上发送文本字段输入 - Sending Textfield input on ButtonClick or Enter Key 用户在字段中输入时,在文本字段中添加$符号 - Adding $ sign into the textfield when the user enter in the field 如果用户输入一个空格作为他们的输入,你会如何将其读为“ ”字符串? - If the user enters a blank space as their input, how would you read that as a “ ” string? 从文本字段存储用户输入 - Storing User Input From a TextField 确保用户不在EditText中输入空格 - Ensuring a user doesn't enter a space in an EditText 如何在用户输入Java时拆分提供的字符串? - How to split string provided as user enter in java? 我如何向用户询问字符串输入? (如果他们想输入中心和半径,或直径的端点?)(阅读输入) - How do I ask the user for String inputs ? (if they want to enter center and radius, or endpoints of diameter?) (Read an input) 使用 Scanner 读取用户输入时是否可以使用 enter 键作为分隔符,但不能使用“\\n”? - Can I use the enter key as a delimiter when using Scanner to read user input, but not "\n"? 在文本字段旁边添加文本以描述用户期望输入的数据 - Adding text next to a textfield to describe what data the user is expected to enter into it
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM