Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C 

function in c fill a table

i have some problem i couldn't fill some data in a table it's like an infinity loop


PHP Code

<?php 
#include <stdio.h>
#include <stdlib.h>

void saisie (int n){
printf("donner n : \n");
scanf("\n %i",&n);



}

void remplire(int * t,int n){

for(
int i = 0 ;i<n;i++){

    
printf("donner t[%i]",i);
    
scanf("\n %i",&t[i]);
}


}


void affiche (int * t,int n){
for (
int i = 0 ;i < n ;i++){
    
printf("%d",t[i]);

}

}



 
main(){
int n;
int t[20];
saisie(n);
remplire(t,n);
affiche(t,n);

} 
Writeln('Give me a Target >');
[Image: giphy.gif]
you didnt gave value for > int n
int n = 10;
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
(Jan 6, 2021 01:16 PM)HFDone Wrote:  you didnt gave value for > int n
int n = 10;

i will give it with the void saisie
PHP Code

<?php 
void saisie 
(int * n){
printf("donner n : \n");
scanf("%i",&n);



} 
Writeln('Give me a Target >');
[Image: giphy.gif]
main(){
int n = 20;
int t[20];
saisie(n);
remplire(t,n);
affiche(t,n);
return 0;
}
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
as HFdone mentioned you have not initialized your int n;
This looks very complicated... very complex.... very intricate.
I need help with this too
(Jan 26, 2021 05:36 PM)Inveil Wrote:  I need help with this too

pm me
Writeln('Give me a Target >');
[Image: giphy.gif]
(Jan 6, 2021 12:43 PM)blackcoder00 Wrote:  i have some problem i couldn't fill some data in a table it's like an infinity loop


PHP Code

<?php 
#include <stdio.h>
#include <stdlib.h>

void saisie (int n){
printf("donner n : \n");
scanf("\n %i",&n);



}

void remplire(int * t,int n){

for(
int i = 0 ;i<n;i++){

    printf("donner t[%i]",i);
    scanf("\n %i",&t[i]);
}


}


void affiche (int * t,int n){
for (
int i = 0 ;i < n ;i++){
    printf("%d",t[i]);

}

}



 
main(){
int n;
int t[20];
saisie(n);
remplire(t,n);
affiche(t,n);

} 

Use *int on your function saisie to modify the 'n' value
Wow! I haven't programmed in C in years but I can see that you are lacking even the most fundamental understanding of the language.

Example.. What is the function supposed to do? It makes no sense?

Code
void saisie (int n){
  printf("donner n : \n");
  scanf("\n %i",&n);
}

The way you have it written.You have a function which accepts an integer and then you overwrite that integer via scanf and then throw the value away.
May you be given directions by software engineer document writers.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C] by FhackMar 2, 2022 03:52 AM 4 305 Mar 2, 2022 03:52 AM
Last Post: Fhack
[Python] by uzolSep 4, 2020 10:06 PM 4 204 Sep 4, 2020 10:06 PM
Last Post: uzol
[Shell] by bat9hackMar 2, 2019 12:39 PM 1 247 Mar 2, 2019 12:39 PM
Last Post: hamid1615