The example program of C on point
计划一:
#include<stdio.h> #define N_VALUES 5 int main( void )
{
float values[N_VALUES];
float *vp; for( vp = &values[0]; vp < &values[N_VALUES]; )
*vp++ = 0; for( vp = &values[N_VALUES]; vp > &values[0]; )
*--vp =0; for( vp = &values[N_VALUES]; vp >= &values[0]; vp-- )
*vp = 0;
//不建议使用 数组下标越界
//标准同意指向数组元素的指针与最后一个元素内存位置的指针进行比較
//不同意第一个元素和之前内存位置的指针比較 return 0;
}
程序二:
/*
**Programe6.1
**计算一个字符串的函数
*/
#include<stdio.h>
int strlen(char *string)
{
int lenth=0;
while(*string++!='\0')
lenth++;
return lenth;
}
int main(void)
{
char *string = NULL;
string="zxczxc";
printf("%d",strlen(string));
return 0;
}
自己写库函数 真好玩~
程序三:
/*
**Programe6.2 在一组字符串中查找 版本号1
**给定一个指向以NULL结尾的指针列表的指针。在列表的字符串中查找一个特定的字符。
*/ #include<stdio.h>
#define TRUE 1
#define FALSE 0 int find_char( char **strings, char value )
{
char *string; //我们当前源字符串 /*
**对于列表中每一个字符串的处理
*/
while( ( string = *strings++ ) !=NULL )
{
/*
**遍历每一个字符串 是否为目标字符串
*/
while( *string != '\0' )
{
if( *string ++ == value)
return TRUE;
}
}
return FALSE;
}
int main( void )
{
char* str[3][10]={"sdf","sdfdhf","fdghdf"};
int result = find_char(str[0],'x');
printf("%d",result);
return 0;
}
一个指向数组确实无法使用 瞎蒙 实际测试的~
The example program of C on point的更多相关文章
- [project euler] program 4
上一次接触 project euler 还是2011年的事情,做了前三道题,后来被第四题卡住了,前面几题的代码也没有保留下来. 今天试着暴力破解了一下,代码如下: (我大概是第 172,719 个解出 ...
- Solved: “Cannot execute a program. The command being executed was \roslyn\csc.exe”
When you publish your ASP.NET project to a hosting account such as GoDaddy, you may run into the iss ...
- 关于The C compiler "arm-none-eabi-gcc" is not able to compile a simple test program. 的错误自省...
在 GCC ARM Embedded https://launchpad.net/gcc-arm-embedded/ 上面下载了个arm-none-eabi-gcc 用cmake 编译时 #指定C交叉 ...
- c中使用gets() 提示warning: this program uses gets(), which is unsafe.
今天在C代码中使用gets()时提示“warning: this program uses gets(), which is unsafe.”,然后这个程序还能运行,无聊的我开始查阅资料,为啥gets ...
- Unable to load R3 module D:\Program Files\Oracle\VirtualBox/VBoxDD.DLL (VBoxDD): GetLastError=1790 (VERR_UNRESOLVED_ERROR).
Unable to load R3 module D:\Program Files\Oracle\VirtualBox/VBoxDD.DLL (VBoxDD): GetLastError=1790 ( ...
- Git for Windows - The Program can't start because libiconv2.dll is missing
今天在新装的win10 预览版上面,发现git不能启动了,提示信息主要是: The Program can't start because libiconv2.dll is missing 于是我在网 ...
- C:\Program Files (x86)\Common Files\microsoft shared\DevServer\10.0
C:\Program Files (x86)\Common Files\microsoft shared\DevServer\10.0
- Program.cs
Program.cs using System; namespace HelloWorld { class Program { [STAThread] static void Main(string[ ...
- sudo: no tty present and no askpass program specified(转)
sudo: no tty present and no askpass program specified 2012-11-30 09:30 5040人阅读 评论(1) 收藏 举报 修改sudo配置文 ...
- 委托的例子,from C# advanced program
class BubbleSorter { static public void Sort<T>(IList<T> sortArray, Func<T, T, bool&g ...
随机推荐
- C语言常用的宏
01: 防止一个头文件被重复包含 #ifndef COMDEF_H #define COMDEF_H //头文件内容 #endif 02: 重新定义一些类型,防止由于各种平台和编译器的不同,而产生的类 ...
- 如何获取ul 中li选中的值点击button按钮跳转链接
<ul id="parent"> <li></li> <li></li> <li></li> & ...
- NET单元测试的艺术
NET单元测试的艺术 开篇:上一篇我们学习基本的单元测试基础知识和入门实例.但是,如果我们要测试的方法依赖于一个外部资源,如文件系统.数据库.Web服务或者其他难以控制的东西,那又该如何编写测试呢?为 ...
- Android - JNI静态(static)载入OpenCV
JNI静态(static)载入OpenCV 本文地址: http://blog.csdn.net/caroline_wendy 步骤: 1. 准备OpenCV-Android库 复制OpenCV的sd ...
- cocos2d-x(十二)Lua开发飞机大战-7-加入敌机
Lua本是一门面向过程的解释性语言.但在开发过程中有很多人还是习惯于面向对象编程.在Lua中我们能够使用table模拟类.只是写起来不太爽(特别是在继承一些C++类的时候).通过查看演示样例.发现co ...
- 部署、收回和删除解决方式----STSADM和PowerShell
部署.收回和删除解决方式----STSADM和PowerShell 由于近期总是要部署wsp解决方式,所以常常要用到命令行或者PowerShell.所以有必要将命令集中放在这里.在部署 ...
- C++ 中获取 可变形參函数中的參数
#include <iostream> #include <stdarg.h> using namespace std; int ArgFunc(const char * st ...
- 采用 audio 和 embed 实现浏览器的兼容性页音频播放
采用 audio 和 embed 实现浏览器的兼容性页音频播放 采用 audio 和 embed 实现浏览器的兼容性页音频播放 学习参考源代码如下所示: function playSound() { ...
- java解析String类型t复杂xml,多级节点,最好的例子
需要用jar包 dom4j-1.6.1.jar 字符串xml如下: <root> <flw> <name>aa</name> <age>22 ...
- poj2763(树链剖分)
题目链接:http://poj.org/problem?id=2763 题意:定一棵带边权的树,要求支持两种操作:1)询问树中某两点间的距离. 2)修改某条边的权值. 分析:树链剖分,边权修改,路径求 ...