我在这做错了什么?
呼叫
printf(filename(exename));
Run Code Online (Sandbox Code Playgroud)
我的函数应该返回文件名
const char* filename(const string& str)
{
const char* path;
size_t found;
found=str.find_last_of("/\\");
path = (str.substr(found+1)).c_str();
cout << str.substr(found+1); // ------------> is name ok
printf("\n\n");
printf(path); // ------------> is name not ok random numbers
printf("\n\n");
return path; // ------------> is not ok random numbers
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试验证我的文本框控件,它应该包含一个介于1和无穷大之间的数字(它不能是0或负数).
我想regularexpressionvalidator在c#中使用a ,rangevalidator当我不希望有一个时,请求最大数字.
我希望是否有人可以帮助我创建一个正则表达式来检查一个和无穷大之间的数字.
我在网上搜索了,我发现了封闭的东西{1,},但是这会导致parsing "{1,}" - Quantifier {x,y} following nothing错误.不太注意正则表达式,但希望有人能帮我找到答案.
假设:
const int n = bigNumber;
float* f = someData;
Run Code Online (Sandbox Code Playgroud)
转换是否有任何意义
for (int i = 0; i < n; i++)
{
f[i] += 1;
}
Run Code Online (Sandbox Code Playgroud)
至
float* lastF = f + n;
for (float* i = f; i < lastF; i++)
{
*i += 1;
}
Run Code Online (Sandbox Code Playgroud)
天真地看着这个,似乎我为每次迭代(the f[i])保存了一个加法运算.
当然,这假设我对循环内的索引器的值没有兴趣.
我会检查拆卸,但我读这些很糟糕.
我是Codeigniter的新手.我在自动加载中有3个库config.php.
但在我的一个控制器中,我不想加载库.这可能吗?
我想检查用户的输入是否是数字.如果是,我希望该功能继续运行,否则想要提醒他并再次运行它.
Console.WriteLine(String.Concat("choose your action" ,Environment.NewLine ,
"1.Deposit", Environment.NewLine,
"2.Withdraw", Environment.NewLine,
"3.CheckAccount"));
string c = Console.ReadLine();
int value = Convert.ToInt32(c);
if (value==char.IsLetterOrDigit(value)) //<----- no good why?
{
switch (value)
{
case 1:
Deposit();
return;
case 2:
Withdraw();
return;
case 3:
CheckAccount();
return;
}
}
Run Code Online (Sandbox Code Playgroud) c# ×2
c++ ×2
asp.net ×1
autoload ×1
codeigniter ×1
optimization ×1
regex ×1
validation ×1
visual-c++ ×1