我正在尝试使用grep查看文件,并找到以小写字母"s"开头的单词.该文件的片段:
sjpope pts/2 161.133.12.95 10:21am 43.00s 0.13s 0.01s man bc
rmschalk pts/3 161.133.9.147 10:22am 1.00s 0.10s 0.02s vi testb
jntrudel pts/4 161.133.9.11 10:23am 2.00s 0.09s 0.00s vi testb
tjbanks pts/5 161.133.9.70 10:41am 8.00s 0.06s 0.04s -ksh
Run Code Online (Sandbox Code Playgroud)
我希望输出的行用"s"表示.
我试图<<在a 上使用运算符long,如下所示:
((long) num3) << ( 2 + (long) num4)))
Run Code Online (Sandbox Code Playgroud)
这给了我以下错误:
运算符<<不能应用于long和long类型的操作数.
如果我没有转换num4为a long,则没有错误.但是,我不能把它作为一个int.还有其他方法吗?
我正在学习MySql,但我遇到了这个问题.以下代码应该只在db表中查询users表中的所有内容.但它返回此错误.Error: SELECT * FROM users这对我毫无帮助.我能够成功地将项目插入数据库,但我无法从中进行选择.我也试过$sql = "SELECT * FROM ama.users";我的数据库结构了
ama
|-users
Run Code Online (Sandbox Code Playgroud)
任何帮助将非常感激.
$conn = new mysqli($_ENV['OPENSHIFT_MYSQL_DB_HOST'],$_ENV['OPENSHIFT_MYSQL_DB_USERNAME'], $_ENV['OPENSHIFT_MYSQL_DB_PASSWORD'], 'ama');
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$username = "Doe";
$password = "johnexample";
$sql = "SELECT * FROM users";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
Run Code Online (Sandbox Code Playgroud) 我正在尝试制作一个命令行程序,它会询问您是否需要快速和长时间发出哔声.我一直System.FormatException在看下面的代码.我马上就遇到了问题Console.WriteLine("how many times should i beep?");.我已经找到了一个修正,console.read();//pause在这一行之后放右.
我的问题是我做错了什么?或者我想在那条线之后暂停?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("how fast would you like the sounds to play?");
Console.WriteLine("70 = fast and 300 = slow can pick any number inbetween");
string choice = Console.ReadLine();
int speed = Convert.ToInt32(choice);
Console.Write(speed);
Console.Read();//pause
Console.WriteLine("how many times should i beep?");
string choice2 = Console.ReadLine();
int j = Convert.ToInt32(choice2);
Console.Write(j);
Console.Read();//pause
for (int …Run Code Online (Sandbox Code Playgroud) 我试图做的是,从文本框中获取用户输入,将其转换为int然后使用它.我得到了一切工作,除了尝试和捕获.如果这个人写了一封信而不是一个数字.使用下面的代码它总是捕获一些东西.我不知道什么是捕获的东西.我已经取出了bool测试,如果我写了一封信,它只会抛出异常然后去发出哔哔声.然后等待有效输入.请原谅我凌乱的代码,我还是初学c#程序员:D谢谢高级!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
bool tone = false;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
bool test = true;
speedInput.Clear();
beep.Clear();
int beepspeed = 90;
int speed = 100;
string speedtext = this.speedInput.Text;
string beeptext = this.beep.Text;
try
{
test = true;
beepspeed = Convert.ToInt32(beeptext);
speed = Convert.ToInt32(speedtext);
}
catch …Run Code Online (Sandbox Code Playgroud) 好吧,所以首先我已经在项目中设置了我正在使用dll的引用.我想要做的是访问我的utils dll中的方法"haha"
dll的代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Utils
{
public class kb
{
public class yes {
public void haha(string yes)
{
int test = Convert.ToInt32(yes);
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
在我试图访问哈哈的项目我只有"Utils.kb.yes",但没有方法...我所能做的就是Utils.kb.yes.equals和Utils.kb.yes.ReferenceEquals.
我正在创建一个将回显我的名字的shell脚本,然后回显"今天的日期"并运行日期.但是当它运行日期时它会删除"今天的日期",我也试过没有管道,并在下一行上有日期命令.但这两个都不像我想要的那样工作.
#Michael LaPan
#3/19/2014
clear
echo Michael LaPan
echo "the date today is:" | date
Run Code Online (Sandbox Code Playgroud)
现在它只是看起来像
Michael LaPan
Wed Mar 19 19:40:53 EDT 2014
Run Code Online (Sandbox Code Playgroud)
我多么希望它看起来
Michael LaPan
the date today is: Wed Mar 19 19:40:53 EDT 2014
Run Code Online (Sandbox Code Playgroud) 我想做的是从网页下载文件。文件下载完成后,我将其打印到屏幕上。
using HtmlAgilityPack;
using NAudio.Wave;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication25
{
class Program
{
static void Main(string[] args)
{
Uri remoteUri = new Uri("http://soundcloud.com/dubstep/spag-heddy-the-master-vip/download");
string fileName1 = "t", myStringWebResource = null;
// Create a new WebClient instance.
using (WebClient myWebClient = new WebClient())
{
myStringWebResource = remoteUri + fileName1;
// Download the Web resource and save it into the current filesystem folder.
myWebClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(Url1_DownloadStringCompleted);
myWebClient.DownloadFileAsync(remoteUri, …Run Code Online (Sandbox Code Playgroud) 在尝试删除指针时,我遇到了崩溃(我怀疑垃圾数据)如果我运行它并输入1并填写问题,则数组递增,并且能够删除.但运行此并输入1两次(均填写数据).我崩溃了 数组递增,并保存我输入的两组数据.由于这是一个学校项目,我也无法使用向量.
#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
#include "fileStuff.h"
bool menu();
bool menuOptions(int option);
void fileIO();
void listAll(interact * obs, int arryO);
interact addOne(interact * obs, int size);
interact subOne(interact * obs, int size);
int main()
{
bool isRunning = true;
while (isRunning)
{
isRunning = menu();
}
return 0;
}
interact addOne(interact * obs, int size)
{
interact *temp = new interact[size];
cout << temp[0].getBagId() << " from method." << endl;
for (int …Run Code Online (Sandbox Code Playgroud)