chao moi nguoi! Minh muon truyen con tro a vao trong ham nhap. Sau do goi ham hien thi de hien thi ra. Van de o day la sau khi ra khoi ham nhap cac gia tri nhap vao bien a ko con nua. Minh da thu chay chuong trinh nay voi dieu kien bien a la public. Nhung bi jo minh muon truyen no qua ham vay minh phai lam thie nao xin moi nguoi chi jao. Minh cam on. Day la doan code cua minh
#include<stdio.h>
#include<stdlib.h>

int* nhap(int *a,int n){
    a=(int*)malloc(n*sizeof(int));
    if(a!=NULL)
    for (int i=0;i<n;i++)
      {
          printf("a[%d]=",i);
          scanf("%d",&a[i]);
}
    else
      printf("\nLoi!!!");
    return a;
}

void HienThi(int * a,int n) {
  for (int i=0;i<n;i++)
  printf("  %d",a+i);
}
int main(){
  int n,*a;
    printf("\nNhap so chieu:");
    scanf("%d",&n);
    a=nhap(a,n);
    HienThi(a,n);
    free(a);
    return 0;
}

Ngo Trung Nhan <[EMAIL PROTECTED]> wrote:
http://c-faq.com/stdio/scanfprobs.html

On 9/14/06, NAHieu <[EMAIL PROTECTED]> wrote:
> On 9/14/06, G TT <[EMAIL PROTECTED]> wrote:
> > Vi` "white spaces" ddu+o+.c xem nhu+ "string terminator", ne^n xem ma~:
> >
> > #inclue
> > int main()
> > {
> > char str[80];
> > printf("Enter some words (or 'ctrl-c' to break): ");
> > scanf("%s", str); <====== buffer length unchecked HERE
>
> It is a very *stupid* idea to use scanf() to get input!
> fgets() is certainly a better choice in this case.
> RTFM!
>
>
> Cheers,
> H
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> VietLUG-users mailing list
> VietLUG-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/vietlug-users
>

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
VietLUG-users mailing list
VietLUG-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vietlug-users


Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2ยข/min or less.
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
VietLUG-users mailing list
VietLUG-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vietlug-users

Trả lời cho