我想从Windows中的命令提示符编译C代码.我已将环境变量添加到PATH中,我可以使用以下命令编译.cs文件:csc app.cs
没关系,但是如何编译app.c?
如果在C中做了一些编程,那么学习OOP的最佳途径是什么?
我的意图是首先采取自然的飞跃,并"与一个增量",然后去Stroustrup.但是,因为我得到了小老Bertrand Meyer的OOSC2,并且我从附录第1135页开始说道."根据Donald Knuth的说法,这会让Edsger Dijkstra身体不适,想到用C++编程" 和Meyer本人"...... C++不是理想的OOP语言......"
如果我的意图是对现代OOP语言的深刻理解,我是否应该跳过C++并直接使用C#和Java?或者我是否会错过C++中关于此主题的优点?
嗯,我知道这是一个讨论的事情,但我把它标记为wiki,你的答案对我来说可能意味着很多选择.
如果我想在使用分号分隔符读取文件时将旧C代码"升级"为更新的C++,那么最佳选择是什么:
/* reading in from file C-like: */
fscanf(tFile, "%d", &mypost.nr); /*delimiter ; */
fscanf(tFile, " ;%[^;];", mypost.aftername);/* delimiter ; */
fscanf(tFile, " %[^;]", mypost.forename); /*delimiter ; */
fscanf(tFile, " ;%[^;];", mypost.dept);/*delimiter ; */
fscanf(tFile, " %[^;];", mypost.position);/* delimiter ; */
fscanf(tFile, "%d", &mypost.nr2);
//eqivalent best C++ method achieving the same thing?
Run Code Online (Sandbox Code Playgroud) 是否可以运行多个Netbeans实例,就像在Win 32平台上使用Visual Studio一样?我可以点一个.
Visual Studio 2008中的错误消息是什么?
Error 1 error C2144: syntax error : '__w64 unsigned int' should be preceded by ';' c:\program files\microsoft visual studio 9.0\vc\include\codeanalysis\sourceannotations.h 19 Steg2_Labs
Run Code Online (Sandbox Code Playgroud)
我自己没有任何headerfiles.
如何在函数中切换指针?
void ChangePointers(int *p_intP1, int *p_intP2);
int main() {
int i = 100, j = 500;
int *intP1, *intP2; /* pointers */
intP1 = &i;
intP2 = &j;
printf("%d\n", *intP1); /* prints 100 (i) */
printf("%d\n", *intP2); /* prints 500 (j) */
ChangePointers(intP1, intP2);
printf("%d\n", *intP1); /* still prints 100, would like it swapped by now */
printf("%d\n", *intP2); /* still prints 500 would like it swapped by now */
}/* end main */
void ChangePointers(int *p_intP1, int *p_intP2) { …Run Code Online (Sandbox Code Playgroud) 下面的内容是不是arrayname总是指向C中第一个元素的指针?
int myArray[10] = {0};
printf("%d\n", &myArray); /* prints memadress for first element */
printf("%d\n", myArray); /* this prints a memadress too, shows that the name is a pointer */
printf("%d\n",sizeof(myArray)); /* this prints size of the whole array, not a pointer anymore? */
printf("%d\n",sizeof(&myArray)); /* this prints the size of the pointer */
Run Code Online (Sandbox Code Playgroud) 你如何得到cout的"绝对定位"列,左对齐文本和右对齐数字?
#include <iostream>
#include <iomanip>
using namespace std;
struct Human {
char name[20];
char name2[20];
char name3[20];
double pts;
};
int main() {
int i;
Human myHumen[3] = {
{"Mr", "Alan", "Turing", 12.25},
{"Ms", "Ada", "Lovelace", 15.25},
{"Sir", "Edgar Allan", "Poe", 45.25}
};
cout << "Name1" << setw(22) << "Name2" << setw(22) << "Name3" << setw(22) << "Rating" <<endl;
cout << "-----------------------------------------------------------------------\n";
for(i = 0; i < 3; i++) {
cout << myHumen[i].name << setw(22) << myHumen[i].name2 << setw(22) << …Run Code Online (Sandbox Code Playgroud) 如何在C++中对字符串数组进行排序,以便按以下顺序进行:
安卡先生
布朗先生
塞瑟先生
mR donK
先生
Ätt先生
先生
//following not the way to get that order regardeless upper or lowercase and å, ä, ö
//in forloop...
string handle;
point1 = array1[j].find_first_of(' ');
string forename1(array1[j].substr(0, (point1)));
string aftername1(array1[j].substr(point1 + 1));
point2 = array1[j+1].find_first_of(' ');
string forename2(array1[j+1].substr(0, (point2)));
string aftername2(array1[j+1].substr(point2 + 1));
if(aftername1 > aftername2){
handle = array1[j];
array1[j] = array1[j+1];
array1[j+1] = handle;//swapping
}
if(aftername1 == aftername2){
if(forname1 > forname2){
handle = array1[j];
array1[j] = array1[j+1];
array1[j+1] = handle;
} …Run Code Online (Sandbox Code Playgroud)