小编Cap*_*ing的帖子

PHP随机字符串生成器

我正在尝试在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)

我究竟做错了什么?

php string random

772
推荐指数
27
解决办法
117万
查看次数

变量'fstream grabpass'具有初始值但不完整的类型

我在第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)

c++

10
推荐指数
1
解决办法
8726
查看次数

错误:"初始化表达式列表被视为复合表达式"

我在编译基本密码保护文件程序的开头时遇到问题,我在第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)

c++ parameters declaration function

3
推荐指数
2
解决办法
5万
查看次数

C++中的字符串溢出?这种无聊的嘟嘟声很奇怪

我正在开发一个垃圾文件生成器,但由于某种原因,如果我使用大数字,它将无限地发出哔声,直到文件完成,我认为在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)

c++ string buffer-overflow

0
推荐指数
1
解决办法
349
查看次数

外部CSS样式表链接失败

我在这里遇到这个问题:

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恶意软件警告.

html css

0
推荐指数
1
解决办法
2244
查看次数

标签 统计

c++ ×3

string ×2

buffer-overflow ×1

css ×1

declaration ×1

function ×1

html ×1

parameters ×1

php ×1

random ×1