首页 > 系统服务 > 详细

a c lang in linux

时间:2016-09-02 18:49:13      阅读:146      评论:0      收藏:0      [点我收藏+]
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>


using namespace std;

int main(int argc, char *argv[])
{
char cl = ‘A‘;
cout << ‘W‘ << ‘ ‘;
cout << cl << endl;
cout << "this is a test." << endl;
cout << "----------" << endl;

char *name="howareyou";
char ch;
FILE *fp;
if((fp=fopen("./bs.txt","r"))==NULL){

    cout << "err"<<endl;
}

 ch=fgetc(fp); 
 while(ch!=EOF) 
{
    if(ch==‘\n‘)
    cout<< "a new line"<<endl;
        putchar(ch); 
        ch=fgetc(fp); 
} 
printf("I need %s %d",name,5);

string path="\\home";
cout << path;

return 0;
}

char* readline(FILE* f)
{
    char* line = (char*) calloc(1, sizeof(char) );;
    char c;
    int len = 0;
    
    while ( (c = fgetc(f) ) != EOF && c != ‘/n‘)
    {
        line = (char*) realloc(line, sizeof(char) * (len + 2) );
        line[len++] = c;
        line[len] = ‘/0‘;
    }


    return line;
}

  

a c lang in linux

原文:http://www.cnblogs.com/hualiu0/p/5834494.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!