比较C ++中char数组的值(Comparing the values of char arrays in C++)
我在我的程序中做某件事有问题。 我有一个char [28]数组保存着人的姓名。 我有另一个char [28]数组,它也保留名称。 我要求用户输入第一个数组的名称,第二个数组从二进制文件中读取名称。 然后我将它们与==运算符进行比较,但即使名称相同,当我调试它们时,它们的值也会有所不同。 为什么会这样? 我怎样才能比较这两个? 我的示例代码如下所示:
int main() { char sName[28]; cin>>sName; //Get the name of the student to be searched /// Reading the tables ifstream in("students.bin", ios::in | ios::binary); student Student; //This is a struct while (in.read((char*) &Student, sizeof(student))) { if(sName==Student.name)//Student.name is also a char[28] { cout<<"found"<<endl; break; } }
I have problem about doing something in my program. I have a char[28] array keeping names of people. I have another char[28] array that also keeps names. I ask user to enter a name for the first array, and second arrays reads names from a binary file. Then i compare them with == operator, But even though the names are the same, their values look different when i debug it. Why is this the case? How can i compare these two? My sample code is as follows:
int main() { char sName[28]; cin>>sName; //Get the name of the student to be searched /// Reading the tables ifstream in("students.bin", ios::in | ios::binary); student Student; //This is a struct while (in.read((char*) &Student, sizeof(student))) { if(sName==Student.name)//Student.name is also a char[28] { cout<<"found"<<endl; break; } }
原文:https://stackoverflow.com/questions/15050766
最满意答案
FollowSymLinks
表示如果目录是符号链接,请点击链接
Indexes
意味着如果没有索引页面,dir可以显示为列表。
FollowSymLinks
means if a dir is a symbol link, follow the link
Indexes
means a dir can be show as list if no index page.
相关问答
更多-
FollowSymLinks表示如果目录是符号链接,请点击链接 Indexes意味着如果没有索引页面,dir可以显示为列表。 FollowSymLinks means if a dir is a symbol link, follow the link Indexes means a dir can be show as list if no index page.
-
我知道这可能听起来不对,但在你的plesk域设置中确保选中了cgi支持但是未选中perl支持。 即使使用修改后的Apache conf文件,当使用mod_rewrite规则时,我也无法将403禁止的错误消失。 一旦我取消选中plesk配置中的perl选项,域perl就会重写工作。 I know this may not sound right but in your plesk domain settings make sure cgi support is checked but perl support ...
-
RewriteCond %{HTTP_HOST} ^(www\.)?handmade24\.at RewriteRule ^(.*)$ $1?language=de [QSA,L] RewriteCond %{HTTP_HOST} ^(\w+)\.handmade24\.at RewriteRule ^(.*)$ $1?language=%1 [QSA,L] RewriteCond %{HTTP_HOST} ^(www\.)?handmade24\.at RewriteRule ...
-
这有效,它显示“禁止,您无权访问/在此服务器上的文件夹/”。 而不是“目录列表被拒绝”。 我仍然可以访问该文件夹中的文件。
Options +Indexes +FollowSymLinks +MultiViews Require all granted Options -Indexes +FollowSymLinks +MultiViews Require all granted 您无法使用这些选项尽可能安全地使用这些选项。 使用它们的风险在于,用户或在用户下运行的进程可以通过创建符号链接来披露信息甚至劫持内容。 例如,如果一个没有特权的用户(可能已被入侵)想要读取他们通常无法访问的文件,他们可以通过从他们的public_html目录创建一个符号链接来升级它,如果apache可以读取它,然后他们可以访问他们的网页并阅读文件。 除了确保系统已正确修补和配置之外,您无法做任何具体的事情来防止此类事件发生。 请注意,此威胁不仅来自系统上的用户。 如果你正在运行一个webapp,比如php, ...您可以将ErrorDocument with 403使用: ErrorDocument 403 /error404.html You can use ErrorDocument with 403: ErrorDocument 403 /error404.html.htaccess允许.html(.htaccess to allow .html)[2021-12-26]
要忽略书店目录,您需要一个! 在表达式前面: RewriteCond %{REQUEST_URI} !/bookstore/ 或者,您可以在bookstore目录中的htaccess文件中打开重写引擎,并且文档根目录中的规则将被取代: ../bookstore/.htaccess Options +FollowSymlinks DirectoryIndex index.php index.html index.htm Options +Indexes ErrorDocument 404 /error.ph ...在父htaccess中,这会解决您的情况,还是您可以从dev.domain访问/ blog / path ? RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} ^dev.iber.co.uk$ [NC] RewriteCond %{REQUEST_URI} ^/blog/ [NC] RewriteRule ^/blog/(.*)$ blog.iber.co.uk/$1 [R=302.L] ...您必须将选项放在一行上,或在选项前面添加一个+号,这样Apache才能理解您想要合并它们。 目前只应用最后一个Options指令('Options Indexes MultiViews'),因为它覆盖了所有先前的选项。 试试这个(它会覆盖'/'选项):Options Indexes MultiViews FollowSymLinks SymLinksIfOwnerMatch AllowOverride A ... 回过头来看,提议的解决方案在我的案例中“正常”。 Just to come back at this, the proposed solution 'just works' in my case.相关文章
更多- Guava Chars类-char类型的实用工具类
- 《C/C++图像处理编程》扫描版[PDF]
- 《从零开始学Visual C++》扫描版[PDF]
- 谁给推荐一个C++的JSON库
- Guava CharMatcher类处理JAVA char类型值
- 【Hadoop学习】在伪分布式Hadoop上实践word count程序——C/C++ Pipes版本
- C++ Hadoop实战备忘
- Solr/Lucene escape char handling
- 《轻松学C++编程》扫描版[PDF]
- java server怎样和c++ client实现SSL通信??
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)