我有一个项目模型,看起来像这样:
class Product extends Model
{
public $timestamps = true;
protected $guarded = ['id'];
protected $table = 'products';
protected $hidden = ['created_at', 'updated_at'];
protected $fillable = ['name', 'category_id', 'units', 'b_price', 's_price', 'warn_count', 'added_by'];
public function category()
{
return $this->belongsTo('App\Category');
}
public function stock(){
$product_id = $this->id;
$filter = ['product_id' => $product_id];
//STOCK PLUS
//credit purchases
$cr_purchases = CreditPurchase::where($filter)->sum('qty');
//purchases
$purchases = Purchase::where($filter)->sum('qty');
//returns in
$re_in = ReturnIn::where($filter)->sum('qty');
//STOCK MINUS
//credit sales
$cr_sales = CreditSale::where($filter)->sum('qty');
//sales
$sales = Sale::where($filter)->sum('qty');
//returns out …Run Code Online (Sandbox Code Playgroud) 运行此代码段:
wchar_t *wstr = L"áßå®";
wprintf(L"%s",wstr);
Run Code Online (Sandbox Code Playgroud)
给出输出:
«
代替
áßå®
我是新来的wchar_t.我如何获得预期的输出?
我试图在main()中捕获char*类型异常,但程序崩溃时出现以下消息:在抛出'char const*'实例后调用terminate这是代码:
#include <iostream>
int main ()
{
char myarray[10];
try
{
for (int n=0; n<=10; n++)
{
if (n>9)
throw "Out of range";
myarray[n]='a';
}
}
catch (char * str)
{
std::cout << "Exception: " << str << std::endl;
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)