将字符串数据获取到数组元素并访问它们 [英] get string data into array elements and access them

查看:138
本文介绍了将字符串数据获取到数组元素并访问它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有用户插入的字符串



i想要取该字符串并将其转换为数组





然后查看该数组中的第一个单词(第一个元素)

我也希望在某个单词之后得到文字





我想要的例子





用户输入以下声明


杰克在花园里踢足球





i想要



1-得到(杰克)检查它

2-想要足球后的字符串(中)



如何实现该注释用户输入的字符串由sapce

i have the string which user insert

i want to take that string and convert it to array


then check the first word in that array(first element)
also i want to get text after certain word


example of what i want


user entered the following statement

"jack play football in the garden "


i want to

1- get (jack) to check it
2- want string after football (in)

how to achieve that note that user entered string sperated by sapce

推荐答案





对于这个要求,你需要创建一个字符指针并将用户输入的字符串存储到指针然后穿过字符串...



阅读字符串使用获取功能..



穿过字符串将帮助您找出每个字母以及所需的单词..



数组可用于存储单词,但您不确定如何每个多维数组都有很多大小。





最好使用Char指针代替数组..



谢谢,

Ullas
Hi,

For this requirements you need to create a char pointer and store the string from user input to the pointer and then travel through the string...

For reading the string use gets function..

Travelling through the string will help you to find out each letter and also the required word..

Arrays can be used to store the words but you are not sure about how many size each muti dimensional arrays holds.


its better to use Char pointer instead of array..

Thanks,
Ullas


这篇关于将字符串数据获取到数组元素并访问它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆