// ExampleCodes.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<stdio.h>
#include<iostream>
using namespace std;
char* stringReverse(char* s)
{
char temp, *p,*q;
q = s;
while( *(++q));
for( p = s; p < --q; p++)
{
temp = *p;
*p = *q;
*q = temp;
}
return s;
}
int _tmain(int argc, _TCHAR* argv[])
{
stringReverse("StringReverse");
return 0;
}
Run Code Online (Sandbox Code Playgroud) 有人向我展示了以下代码片段并询问其含义:
if (!pFCT->FBMap(| ( VBQNum - 1 ) / 8 |) & (1 << (7 - ( ( VBQNum - 1 ) % 8)))))
{
stuff
}
Run Code Online (Sandbox Code Playgroud)
而且我被卡在独立的竖条上.我知道两个人在一起意味着"或"只是一个,这意味着什么.
想知道在Objective-C中是否存在接近C++的'const方法'的公认惯例.(C/C++背景下的语言新手)
例如:
class Foo {
public:
void canChangeMemberVars(void);
char* asString(void) const;
};
Run Code Online (Sandbox Code Playgroud)
"asString()"得到一个const this指针,所以即使你变得流氓并决定用实例的成员捣乱它也行不通.从文档的角度来看,我发现标签方法作为const非常有用.
我正在编写一个Objective-C类库,并发现自己希望能够使特定的方法成为常量,并想知道是否有任何语言技巧来实现这一点.
总结:
在一天结束时,实现与Mutable和Immutable版本中的因子类类似的功能的唯一方法是什么?在每个方法的注释中做一个简单的注释对我的目的来说不够严格.
我正在尝试编写一个获取字符串向量并返回指向随机元素的指针的方法.您能告诉我以下代码有什么问题吗?
string* getRandomOption(vector<string> currOptions){
vector<string>::iterator it;
it=currOptions.begin();
string* res;
int nOptions = currOptions.size();
if(nOptions != 1){
int idx = rand() % (nOptions-1);
while (idx!=0){
it++;
idx--;
};
};
res = &(*it);
};
Run Code Online (Sandbox Code Playgroud)
谢谢,李
我的问题很基本,但已经有一段时间了.我正在读取文本文件并将文本中的数字保存到结构"记录"中.在我将文本读入记录缓冲区后,我想将它放在内存区域中.
typedef struct
{
int line_status[64];
float line_data[64], relativetime;
unsigned long blkhdr_ticks;
} Record;
Record *storage;
storage = (Record*)malloc(nRange*sizeof(Record));
Record buffer;
Run Code Online (Sandbox Code Playgroud)
其中nRange是一个随机数,而缓冲区是带有值的记录,但我没有列出我的代码将它们分配给缓冲区.我认为语法是这样的:
&storage = buffer;
Run Code Online (Sandbox Code Playgroud)
但我知道这不对.任何帮助将不胜感激.
我正在写一个简单的循环来确保我的输入是一个有效的二进制文件.例如:当用户输入任何大于1的数字时,我想抛出一个错误.我知道我需要检查ASCII号码.这里发生了什么?输入二进制文件时,我不应该收到错误.有什么想法吗?
for (int i=0;i<size;i++)
{
printf("%i is string sub %i\n",int(binary[i]),i);
if (int(binary[i]) != 48 || int(binary[i]) != 49)
{
printf("ERROR NOT A BINARY NUMBER\n");
exit(0);
}
}
Run Code Online (Sandbox Code Playgroud)
输入:
0101
Run Code Online (Sandbox Code Playgroud)
输出:
48 is string sub 0
ERROR NOT A BINARY NUMBER
Run Code Online (Sandbox Code Playgroud) 嘿,我得到一个关于下一个代码中发生了什么的问题:
typedef struct {
double re,im;
} Complex;
Complex ComplexCreate(double r=0.,doublei=0.)
{
Complex c;
c.re=r;
c.im=i;
return c; // problem with this line
// my question is : is c getting duplicated and returning or does it return nothing
// when i we go back to the main
}
Run Code Online (Sandbox Code Playgroud)
我知道在c ++中,我可以而且应该使用类,这只是我想要了解的一个测试.在此先感谢您的帮助
我见过两个Asterisk C++ API:*Astxx:Asterisk C++ API和Utility库.Asterisk的C++包装器,支持开发人员*C++ Asterisk Manager API包装器.支持从Asterisk服务器接收事件并向Asterisk发送操作.
有人尝试过其中一个项目吗?
提前致谢.