zoukankan      html  css  js  c++  java
  • c语言用指针定义一个类型进行输入输出

    1 整型数组

    //
    
    #include "stdafx.h"
    #include "stdlib.h"
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    int *q=(int*)malloc(sizeof(int)*5);   //malloc函数动态分配5个整型数的地址空间。
    
    printf("Please input:");
    
    for(int i=0;i<5;i++)
    
    scanf("%d",q+i);  
    
    for(int i=0;i<5;i++) 
     
    printf("%d ",*(q+i));
        system("pause");
        return 0;
    }

    2 定义有一个字符串进行输入输出

    #include "stdafx.h"
    #include "stdlib.h"
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    char *str=(char*)malloc(100);   //malloc函数动态分配地址空间。
    
    printf("Please input:");
    
    scanf("%s",str);   
    
    
    printf("%s",str);   //注意 不用加 *
        system("pause"); 
        return 0;
    }
  • 相关阅读:
    模板语法
    django框架中登陆验证功能
    __call__
    JQuery基础
    JS中BOM和DOM操作
    Javascript基础
    css完结
    css深入
    css初识
    html深入解析
  • 原文地址:https://www.cnblogs.com/mhq-martin/p/11392106.html
Copyright © 2011-2022 走看看