C语言/C++ 教程
C语言/C++ 教程:包含了所有代写案例以及部分答案
-
副标题#e# 前几天我在新浪微博上出了两道有关 TCP 的思考题,激发了一场接头 http://weibo.com/1701018393/eCuxDrta0Nn 。 第一道低级题目是: 有一台呆板,它有 一个 IP,上面运行了一个 TCP 处事措施,措施只侦听一个端口,问:从理论上讲(只思量 TCP/IP 这 一层面,不思量IPv6)这个处事措施可以支持几多并发 TCP 毗连?答 65536 上下的直接刷掉。 详细来说,这个问题等价于:有一个 TCP 处事措施的地点是 1.2.3.4:8765, … 继续阅读“关于 TCP 并发毗连的几个思考题与试验”
:
-
#include<stdarg.h> #include<stdio.h> va_list ap;//声明一个变量参数 char buff[80]; int myprintf(char *format,…) { va_start(ap,format); int num; num=vsnprintf(buff,sizeof(buff),format,ap); va_end(ap); return num; } int main() { int a=23;float … 继续阅读“va_list变量参数用法”
:
-
口试常常会碰着的题,C语言实现字符串逆序。如输入“abcd”,输出“dcba”。 最近本身整理了一下,下面代码已颠末测试。 #define Max 200 main() { char str[Max]; printf("请输入字符串:"); gets(str); int len=0; char *strlen=str; char *left=str; char temp; whil … 继续阅读“c语言实现字符串逆序”
:
-
副标题#e# errno 在 <errno.h> 中界说,错误 Exx 的宏界说在 /usr/include/asm-generic 文件夹下面的 errno-base.h 和 errno.h,别离界说了 1-34 、35-132 的错误界说。 strerror() 函数依据 errno 值返回错误描写字符串,下面措施打印比较表: 01.#include <errno.h> 02.#include <string.h> 03.#include <stdi … 继续阅读“Linux errno 错误比较表”
:
-
副标题#e# 1.什么是操纵符重载 可以利用分词将操纵符重载领略为:操纵符+重载。 C++中的操纵符许多,如+,-,*,\等等。 C++中的重载也是C++中面向工具多态的浮现。 简朴说操纵符重载: C++中有:int a=2+3; 那么a=5 操纵符重载可以实现对自界说范例的操纵: #include <iostream> using namespace std; class Point{ public: int x; int y; Point(int _x,int _y):x(_x … 继续阅读“C++的操纵符重载概述”
:
-
副标题#e# 措施31】 题目:请输入礼拜几的第一个字母来判定一下是礼拜几,假如第一个字母一样,则继承判定第二个字母。 1.措施阐明:用环境语句较量好,假如第一个字母一样,则判定用环境语句或if语句判定第二个字母。 2.措施源代码: #include <stdio.h> void main() { char letter; printf("please input the first letter of someday\n"); while ((letter … 继续阅读“C语言措施开拓经典实例之四”
:
-
查察全套“c语言习题集” 题目:用*号输出字母C的图案。 1.措施阐明:可先用’*’号在纸上写出字母C,再分行输出。 2.措施源代码: #include "stdio.h"#include "conio.h"main(){ printf("Hello C-world!\n"); printf(" ****\n"); printf(" *\n"); p … 继续阅读“用*号输出字母C的图案”
:
-
声明template参数时, 前缀要害字class和typename可以交流; 利用要害字typename标识嵌套从属范例名称, 但不需在基类列表和成员初始化列表内利用. 从属名称(dependent names): 模板(template)内呈现的名称, 相依于某个模板(template)参数, 如T t; 嵌套从属名称(nested dependent names):从属名称在class内呈嵌套装, 如T::const_iterator ci; 非从属名称(non-dependent nam … 继续阅读“C++:模板(template)中typename的利用要领”
:
-
用于在接管到某个信号之前,姑且用mask替换历程的信号掩码,并暂停历程执行,直到收到信号为止。 /*The sigsuspend() function replaces the current signal mask of the calling thread with the set of signals pointed to by sigmask and then suspends the thread until delivery of a signal whose action is e … 继续阅读“Linux下C编程:sigsuspend执行进程阐明”
:
-
多重担任, 假如基类(base class)的成员函数名称沟通,重载(overload)函数挪用, 会忽略public和private, 选取最佳的匹配函数, 匹配度沟通, 则会造成歧义, 产堕落误:request for member ‘xxx’ is ambiguous, (GCC) 如需利用, 可以添加详细的域操纵符, 指定类("class::method()"). 代码如下: /* * test.cpp * * Created on: 2014 … 继续阅读“C++:多重担任(multiple inheritance)歧义(ambiguous)”
: