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 ...
随机推荐
- Swift - 文本标签(UILabel)的用法
1,标签的创建 1 2 3 4 5 6 7 8 9 10 import UIKit class ViewController: UIViewController { override func ...
- Spring4 MVC 多文件上传(图片并展示)
开始需要在pom.xml加入几个jar,分别是 <dependency> <groupId>commons-fileupload</groupId> <art ...
- HDU 1548 A strange lift(Dijkstra,简单BFS)
题目大意: 电梯有两个选项向上或向下,每层楼有一个参数ki,代表电梯可以再该楼层的基础上向上或向下移动ki层,限制条件是向上不能超过楼层总数n,向下不能少于一.输入总层数n和当前所在层数以及目标层数, ...
- delphi 自我删除和线程池(1000行代码,需要仔细研究)
unit Unit4; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms ...
- jvm调优经验分享
当Java程序申请内存,超出VM可分配内纯的时候,VM首先可能会GC,假设GC完还是不够,或者申请的直接超够VM可能有的,就会抛出内 存溢出异常.从VM规范中我们能够得到,一下几种异常. java.l ...
- HashTable的数组和连接两种实现方法(Java版本号)
1.散列表的接口类 package cn.usst.hashtable; /** * 散列表的接口类 * @author G-Xia * */ public interface HashTable { ...
- OCP读书笔记(8) - 监控和调优RMAN
监视RMAN作业 1. 创建rman备份: RMAN> run { allocate channel ch1 type disk; allocate channel ch2 type disk; ...
- Struts2 后台action接收 jsp页面中checkbox中的值
如前端页面jsp中的标签为: <form action="myurl"> <input type="checkbox" name=" ...
- android编译自己 内置的jar做法
1.首先 android.mk LOCAL_PATH := $(call my-dir) # ===================================================== ...
- 设置SVN忽略文件和文件夹(文件夹)
在多数项目中你总会有文件和文件夹不须要进行版本号控制.这可能包含一些由编译器生成的文件,*.obj,*.lst,也许是一个用于存放可运行程序的输出文件夹.仅仅要你提交改动,TortoiseSVN 就会 ...