我应该得到一个输入行,可以是以下任何格式:
如何分离1,2和3个单词的情况并将数据放入正确的变量?
word1
word1 word2
word1 word2 , word3
word1 word2,word3
Run Code Online (Sandbox Code Playgroud)
我想到了类似的东西:
sscanf("string", "%s %s,%s", word1, word2, word3);
Run Code Online (Sandbox Code Playgroud)
但它似乎没有用.
我使用严格的C89.
我知道这是一种危险的行为,我只是想知道发生了什么.
代码如下:
#include<stdio.h>
#include<stdlib.h>
static int count = 0;
void hello(void){
count ++;
fprintf(stderr,"hello! %d\n",count);
}
void foo(void){
void *buf[10];
static int i;
for(i = 0 ; i < 100 ; i++){ // put enough data to overwrite the return address on stack
buf[i] = hello;
}
}
int main(void){
int buf[1000];
foo();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
结果如下:
……
hello! 83
hello! 84
hello! 85
hello! 86
hello! 87
hello! 88
hello! 89
Segmentation fault (core dumped)
Run Code Online (Sandbox Code Playgroud)
为什么hello func被称为89次?当foo返回时,pc寄存器获取hello func的地址,不是吗?所以你好叫,然后做什么.那又怎样?程序是不是回到主要功能?89来自哪里?我必须误解一些事情,请指出.
我有一个字符串列表.我想用一个字符串列表填充一个组合框.我该怎么做呢?我所有的尝试和搜索都是死路一条.
我用了:
<ComboBox Name="comboBox2" ItemsSource="{Binding Combobox2items}" />
public partial class EditRule : Window
{
public ObservableCollection<string> Combobox2items { get; set; }
public EditRule()
{
InitializeComponent();
Combobox2items = new ObservableCollection<string>();
Combobox2items.Add("DFd");
}}
Run Code Online (Sandbox Code Playgroud)
编辑:添加Combobox2items.ItemsSource = Combobox2items;
作品,但为什么ItemsSource ="{Binding Combobox2items}"不?
为什么以下代码行不起作用?
typedef float[MAT_ROW_SIZE][MAT_COL_SIZE] mat;
我该怎么办?
(我想避免定义结构)
3我正在尝试使用批处理文件安装Windows服务,我们称之为"setup.bat".在文件中我有以下命令:
"%SystemRoot%\Microsoft.NET\Framework\v4.0.30319\installutil" "MyService.exe"
Run Code Online (Sandbox Code Playgroud)
当我执行批处理文件(在windows7上以管理员身份运行)时,我得到了这个:
初始化安装时发生异常:System.IO.FileNotFoundException:无法加载文件或程序集'file:/// C:\ Win dows\system32\MyService.exe'或其依赖项之一.系统无法指定指定的文件.实际服务位于
"SomeRandomLocation\MyService.exe".
bat文件中
"SomeRandomLocation\setup.bat"
到底是怎么回事?如何从我的"setup.bat"文件夹强制安装它?
这应该是动态的.意思是任何文件夹!
我想有一个类似于制表符控件但没有"TabStrip"部分的控件,而是通过组合框改变制表符.我该怎么做?
我想答案就在那里我只是没有用英语正确地说出来.
我有一个庞大的布尔值数据库,并希望构建一个框架,以便在所有值上轻松运行查询.为此,我想编写一个函数,给定一个布尔表达式的字符串表示,将在数据库的所有元素上计算该表达式.例如,给定输入
(a && b) || c
Run Code Online (Sandbox Code Playgroud)
该函数将构造另一个将要评估的函数
return (funcA() && funcB()) || funcC();
Run Code Online (Sandbox Code Playgroud)
其中funcA,funcB和,funcC是和功能返回布尔值
我得到以下字符串:
"312 ,22 ,+12 , -12 , 5331"
数字之间可以有多个空格.
我需要将它转换为这样的数组:
int arr[] = {312,22,-12,12,5331};
有没有一个漂亮和优雅的方式与C89这样做?
public : array<Byte>^ Foo(array<Byte>^ data)
Run Code Online (Sandbox Code Playgroud)
获取动态大小托管数组
但是如何获得固定大小的托管字节数组呢?
我想强迫C#用户发送8字节数组; 并获得8个字节
样式:
public : Byte[8] Foo(Byte[8] data)
Run Code Online (Sandbox Code Playgroud)
编辑:
任何人都可以解释为什么它在安全环境中的不可能性?
由于非常可怕的原因,我在雇主申请中有这个结构.
我试图覆盖相等运算符,但我得到错误Error 9 Operator '==' cannot be applied to operands of type 'TR_St_DateTime' and 'TR_St_DateTime'
.
我错过了什么?
public struct TR_St_DateTime : IEquatable<TR_St_DateTime>
{
public int Year;
public int Month;
public int Day;
public int Hour;
public int Minute;
public int Second;
public TR_St_DateTime(DateTime time)
{
Day = time.Day;
Hour = time.Hour;
Minute = time.Minute;
Second = time.Second;
Month = time.Month;
Year = time.Year;
}
public override bool Equals(object obj)
{
TR_St_DateTime o = (TR_St_DateTime) obj;
return Equals(o);
}
public …Run Code Online (Sandbox Code Playgroud) c# ×6
.net ×4
c ×4
wpf ×2
algorithm ×1
batch-file ×1
c++ ×1
c++-cli ×1
c89 ×1
input ×1
installutil ×1
parsing ×1
service ×1
tabcontrol ×1
token ×1