LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-29-2013, 06:47 PM   #1
islam_assi
LQ Newbie
 
Registered: May 2013
Location: Palestine
Posts: 6

Rep: Reputation: Disabled
problem in testing a c code in terminal


Hello
I made a directory,I put in it two files exo1.h and exo1.c

but when I want to test the code by typing (./exo1) in terminal I received this message :-
(bash: ./exo1: No such file or directory)



I put this code in exo1.h :-

----------------------------------------
#ifndef exo1
#define exo1

// Print all divisor of an integer
int allDivisors(int n);

#endif
----------------------------------------

and this code in exo1.c :-

--------------------------------------------------
#include "exo1.h"
#include "stdlib.h"
#include "stdio.h"

/**
compute and print all divisors
@param n: the integer
*/
int allDivisors(int n){
int i;
for(i = 2;i<n/2+1;i++)
if(n%i==0)
printf("%d\n",i);
}

int main(){
int nb=-1;
do {
printf("A positive integer please :");
scanf("%d",&nb);
}while(nb<=0);
printf("The all divisors for %d is: \n",nb);
allDivisors(nb);
}
------------------------------------------------------------------
 
Old 05-29-2013, 07:40 PM   #2
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

you need to compile the code into an executable first. Eg
Code:
gcc -o exo1 exo1.c
Then, assuming your c code is ok, the executable exo1 should have been created.

Evo2.
 
2 members found this post helpful.
Old 05-30-2013, 05:57 AM   #3
islam_assi
LQ Newbie
 
Registered: May 2013
Location: Palestine
Posts: 6

Original Poster
Rep: Reputation: Disabled
thaaaaanks
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
regression testing FORTRAN code SuSE vs RH 6.4 getting very different answers rlsmithga Programming 5 06-08-2013 05:05 PM
regression testing FORTRAN code SuSE vs RH 6.4 getting very different answers rlsmithga Linux - Software 1 05-19-2013 11:20 PM
Installing nautilus-terminal in Debian-testing rng Debian 3 12-16-2012 09:38 AM
LXer: Testing Linux Code LXer Syndicated Linux News 0 06-06-2012 05:11 AM
Testing network card by C code Jamesminh Programming 2 10-01-2004 12:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration