我正在尝试在PHP中创建一个随机字符串,我绝对没有输出:
<?php
function RandomString()
{
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randstring = '';
for ($i = 0; $i < 10; $i++) {
$randstring = $characters[rand(0, strlen($characters))];
}
return $randstring;
}
RandomString();
echo $randstring;
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我在第37行使用fstream从文件中读取错误(fstream grabpass("passwords.txt");)但似乎我做错了什么.
#include <iostream>
#include <conio.h>
#include <string>
using namespace std;
int i,passcount,asterisks;
char replace, value, newchar;
string username,password,storedUsername,storedPassword;
int login(string username, string password)
{
if (username=="test"/*storedUsername*/)
{
if (password==storedPassword)
cout<<"Win!";
else
cout<<"Username correct, password incorrect.";
}
else cout<<"Lose. Wrong username and password.";
}
int main()
{
cout<<"Username: ";
cin>>username;
cout<<"Password: ";
do
{
newchar = getch();
if (newchar==13)break;
for (passcount>0;asterisks==passcount;asterisks++)cout<<"*";
password = password + newchar;
passcount++;
} while (passcount!=10);
fstream grabpass("passwords.txt");
getline(grabpass,storedPassword);
grabpass.close();
login(username,password);
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我在编译基本密码保护文件程序的开头时遇到问题,我在第11行遇到了上述错误,(int login(用户名,密码)).不知道这里发生了什么,所以如果有人能够对这种情况有所了解,那就太好了.
#include <iostream>
#include <conio.h>
#include <string>
using namespace std;
int i,passcount,asterisks;
char replace, value, newchar;
string username,password,storedUsername,storedPassword;
int login(username,password);
{
if (username==storedUsername)
{
if (password==storedPassword)
cout<<"Win!";
else
cout<<"Username correct, password incorrect."
}
else cout<<"Lose. Wrong username and password.";
}
int main()
{
cout<<"Username: ";
cin>>username;
cout<<"Password: ";
do
{
newchar = getch();
if (newchar==13)break;
for (passcount>0;asterisks==passcount;asterisks++)cout<<"*";
password = password + newchar;
passcount++;
} while (passcount!=10);
ifstream grabpass("passwords.txt")
grabpass>>storedpass;
grabpass.close();
login(username,password);
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我正在开发一个垃圾文件生成器,但由于某种原因,如果我使用大数字,它将无限地发出哔声,直到文件完成,我认为在ascii表中某处有一个字符,或者它溢出并导致错误蜂鸣声.有人想解释为什么这件事在尖叫我吗?
#include <string>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <time.h>
#include <windows.h>
#define print cout<<
using namespace std;
int numberof,i;
char charvalue;
string charlist,filename;
int main()
{
srand (time(NULL));
print "What do you want the name of your file to be?(with a .txt extension)\n";
getline(cin,filename);
print "\nHow many characters do you want?\n";
cin>>numberof;
for(numberof>0;numberof!=0;numberof--)
{
i = rand() % 255 + 32;
charvalue=i;
charlist=charlist+charvalue;
print charlist;
}
ofstream writefile(filename.c_str());
writefile<<charlist;
writefile.close();
ShellExecute(NULL, "open", filename.c_str(), NULL, NULL, SW_SHOWNORMAL); …Run Code Online (Sandbox Code Playgroud) 我在这里遇到这个问题:
http://arflux-rpg.com/game/index.php
第5行:
<link type="text/css" rel="stylesheet" href="/src/style.css">
Run Code Online (Sandbox Code Playgroud)
样式表存在(并以正确的语法填充),我正确链接,但样式无法应用.
编辑:删除了链接的可点击性,因为它产生了Google恶意软件警告.