码迷,mamicode.com
首页 > 系统相关 > 详细

a c lang in linux

时间:2016-09-02 18:49:36      阅读:184      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!