473,394 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

'unable to open input file' error when trying to use srand()

33
i have a error msg when i want to run my programm.i hope u dont mind is c am using. the error msg is (unable to open input file). the program is as writtn below , pls help me out. i want the program to generate random numberr b/w 1000 and 2500 ten times

Expand|Select|Wrap|Line Numbers
  1. /* mmm emeka*/
  2.  
  3. # include <stdio.h>
  4. # include <stdlib.h>
  5. # include <time.h>
  6.  
  7. int main()
  8. {
  9.     int i;
  10.     srand(time (NULL));
  11.  
  12.     FOR(i = 1; i<=10;i++){
  13.            printf("%10d", 1000 + (rand()%2500);
  14.     }
  15.  
  16.     return 0
  17. }
Feb 14 '07 #1
2 2998
sicarie
4,677 Expert Mod 4TB
menyki-

There were serveral things I commented on in the code below.

Expand|Select|Wrap|Line Numbers
  1. /* mmm emeka*/
  2.  
  3. #include <stdio.h>  // at the moment, my compiler is down, but I'm 99% sure you need to have no spaces in between the # and the word 'include'
  4. #include <stdlib.h>
  5. #include <time.h>
  6.  
  7. int main()
  8. {
  9.     int i;
  10.     srand(time (NULL));
  11.  
  12.     FOR(i = 1; i<=10;i++){             // keywords in C++ are all lowercase
  13.            printf("%10d", 1000 + (rand()%2500);   // you are missing a final ')' at the end to close the printf statement
  14.     }
  15.  
  16.     return 0 // every statement line in C++ ends with a ';' semicolon
  17. }
Once you fix those, your program should compile!
Feb 14 '07 #2
1) change caps FOR to for where c is case sensitive.....
2) terminate the return 0 ; using semicolon
3) Check the no of brackets in the printf.....

Try the below code....
Expand|Select|Wrap|Line Numbers
  1. # include <stdio.h>
  2. # include <stdlib.h>
  3. # include <time.h>
  4.  
  5. int main()
  6. {
  7.     int i;
  8.     srand(time (NULL));
  9.  
  10.     for(i=1;i<=10;i++)
  11.     {
  12.            printf("%10d", 1000 + (rand()%2500));
  13.     }
  14.     return 0;
  15. }
  16.  
Feb 14 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: lawrence | last post by:
I'm probably missing something obvious, but I'm unable to write a file with this function. I've used my FTP software to set permissions to 777 on all the files in question. I've tried r, r+, w, and...
6
by: haynesc | last post by:
Hi, I'm having a problem where when trying to open a file in write mode, I get an IOError stating no such file or directory. I'm calling an external program which takes an input file and...
10
by: soup_or_power | last post by:
The pop up window has several checkboxes. I'm unable to access the checkboxes using the handle from window.open. Any way to do this? var display; function showSugg(but_id, sugg1, sugg2, sugg3,...
0
by: bazzer | last post by:
hey, im trying to access a microsoft access database from an ASP.NET web application in visual basic 2003.NET. i get the following error when i try running it: Server Error in...
0
by: Steven Bolard | last post by:
Hello, I am trying to port my .net 1.1 application to 2.0. I am using vs2005. I am trying to get my webservices to run and although i can compile them and and get wsdl and service descriptions...
0
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
3
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted...
11
by: benoitc | last post by:
I've been having a problem debugging an ASP.NET 1.1 application on an existing Windows XP/Visual Studio 2003 workstation that I've inherited from somebody else. The application builds fine, but...
5
by: kailashchandra | last post by:
I am trying to upload a file in php,but it gives me error msg please Help me? My Code is like below:- i have one php file named upload.php and i have another html file named upload.html and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.