如何检查用户是否已存在于日志文件中? [英] How to check whether the user already exist in a log file or not?

查看:122
本文介绍了如何检查用户是否已存在于日志文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个代码登录框,现在我需要为usernames添加唯一性..我拿了一个数组并从文件中存储了所有现有用户数据...我需要比较一下,我怎么能比较单个变量与数组

解决方案

您可以使用支持唯一性的容器代替数组,例如

http://www.cplusplus.com/reference/unordered_map/unordered_map [ ^ ]。

在这种情况下,用户名应该用作密钥,以及所有用户信息作为值(映射)类型 T



对于大量用户信息,您可以使用关系数据库,你必须有一个用户表,其中用户名作为主键。



-SA

存储为通过读取预先存在的文件来获取数组,并通过指向每个索引值进行比较并继续执行进一步的步骤


I wrote a code to login box,now i need to add uniqueness to usernames..i tooked an array and stored all existing users data from file...i need to compare that,how i can compare a single variable with an array

解决方案

Instead of array, you can use a container which support uniqueness, for example
http://www.cplusplus.com/reference/unordered_map/unordered_map[^].
In you case, the user name should be used as a key, and all user information as a value (mapped) type T.

For big volume of user information, you could use a relational database, and you would have to have a users table where a user name is used as a primary key.

—SA


Stored in form of array by reading the pre-existing file, and compared by pointing at each index values and proceeded with further steps


这篇关于如何检查用户是否已存在于日志文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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