473,387 Members | 1,481 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,387 software developers and data experts.

opening other files using C

Is it possible to open other files in C during main() execution.
Example, i want to open a wave file that generates a sound when ever
main() function is called.

Jun 9 '07 #1
12 1411
mo*********@gmail.com wrote:
Is it possible to open other files in C during main() execution.
Yes.

Your C book surely mentions this?

--
Terse Hedgehog
"It took a very long time, much longer than the most generous estimates."
- James White, /Sector General/

Jun 9 '07 #2
mo*********@gmail.com said:
Is it possible to open other files in C during main() execution.
Yes. Look up fopen, fclose, fread, fwrite, fseek, ftell, fgetpos,
fsetpos, fputc, fgetc, getc, putc, fgets, fputs, fscanf, fprintf, feof,
ferror, and no doubt a few I've forgotten.
Example, i want to open a wave file that generates a sound when ever
main() function is called.
Opening the file is easy. Playing the sound is harder, and C has no
standard way to generate sounds (unless you count writing '\a' to
stdout, which doesn't apply in this case). You'll need to ask how to do
this in a newsgroup dedicated to your implementation.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Jun 9 '07 #3
<mo*********@gmail.comwrote:
Is it possible to open other files in C during main() execution.
Example, i want to open a wave file that generates a sound when ever
main() function is called.
It's possible you used the wrong magic words (open) Look up system() in
<stdlib.h>, it may be what you want..
Jun 9 '07 #4
osmium wrote:
<mo*********@gmail.comwrote:
>Is it possible to open other files in C during main() execution.
Example, i want to open a wave file that generates a sound when
ever main() function is called.

It's possible you used the wrong magic words (open) Look up
system() in <stdlib.h>, it may be what you want..
Nonsense. Look up fopen and fclose in the standard library. Also
FILE*.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
<http://kadaitcha.cx/vista/dogsbreakfast/index.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

Jun 9 '07 #5
"CBFalconer" writes:
osmium wrote:
><mo*********@gmail.comwrote:
>>Is it possible to open other files in C during main() execution.
Example, i want to open a wave file that generates a sound when
ever main() function is called.

It's possible you used the wrong magic words (open) Look up
system() in <stdlib.h>, it may be what you want..

Nonsense. Look up fopen and fclose in the standard library. Also
FILE*.
Now you've added mind reading to your vast repertoire of talents?

It seems quite plausible that he wanted to generate a sound when main was
entered. Windows has terminology which encourages such use, point at a
*data* file and you can get a menu item that says "Open", which has the
meaning "Execute the program associated with this file extension".

If *I* wanted to open a file, I can't imagine ever being so young that I
would have included the word "main" in my question. Main has nothing to do
with anything of interest. I hope the OP will make clear what he really
wanted to know.

And even if you are right, there are less obnoxious and abrasive words to
use than "nonsense" to describe your exalted conclusions.
Jun 9 '07 #6
In article <46***************@yahoo.com>,
CBFalconer <cb********@maineline.netwrote:
>>Is it possible to open other files in C during main() execution.
Example, i want to open a wave file that generates a sound when
ever main() function is called.
>It's possible you used the wrong magic words (open) Look up
system() in <stdlib.h>, it may be what you want..
>Nonsense. Look up fopen and fclose in the standard library. Also
FILE*.
The post you replied to was questioning whether the OP meant something
different by "open". In which case system() might well be the right
solution.

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Jun 9 '07 #7
On Jun 9, 10:53 am, CBFalconer <cbfalco...@yahoo.comwrote:
osmium wrote:
<mohdalib...@gmail.comwrote:
Is it possible to open other files in C during main() execution.
Example, i want to open a wave file that generates a sound when
ever main() function is called.
It's possible you used the wrong magic words (open) Look up
system() in <stdlib.h>, it may be what you want..

Nonsense. Look up fopen and fclose in the standard library. Also
FILE*.
What makes you so certain it is nonsense? It makes perfect sense to
me. The original question seemed odd - how could anyone question
whether files could be opened in a major language like C? Osmium's
guess as to the real meaning of the question rings true, since in many
UI environments these days "opening" a file implies executing a
program which does something vaguely appropriate with the contents.
This concept of "opening" a file is complex, and it's not obvious how
to do it from a look at a C text book or the web. Unless the OP is
incredibly lazy or stupid, it seems much more likely that he's asking
about this rather than fopen, and has simply used terminology which is
not entirely appropriate in a C context.

Jun 9 '07 #8
"J. J. Farrell" wrote:
On Jun 9, 10:53 am, CBFalconer <cbfalco...@yahoo.comwrote:
>osmium wrote:
>><mohdalib...@gmail.comwrote:
>>>Is it possible to open other files in C during main() execution.
Example, i want to open a wave file that generates a sound when
ever main() function is called.
>>It's possible you used the wrong magic words (open) Look up
system() in <stdlib.h>, it may be what you want..

Nonsense. Look up fopen and fclose in the standard library. Also
FILE*.

What makes you so certain it is nonsense? It makes perfect sense to
me. The original question seemed odd - how could anyone question
whether files could be opened in a major language like C? Osmium's
guess as to the real meaning of the question rings true, since in many
UI environments these days "opening" a file implies executing a
program which does something vaguely appropriate with the contents.
This concept of "opening" a file is complex, and it's not obvious how
to do it from a look at a C text book or the web. Unless the OP is
incredibly lazy or stupid, it seems much more likely that he's asking
about this rather than fopen, and has simply used terminology which is
not entirely appropriate in a C context.
Well, I tend to take words in the standard meaning. I never even
considered the other alternative.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
<http://kadaitcha.cx/vista/dogsbreakfast/index.html>
cbfalconer at maineline dot net

--
Posted via a free Usenet account from http://www.teranews.com

Jun 9 '07 #9
On 10 Jun., 05:41, CBFalconer <cbfalco...@yahoo.comwrote:

So what do you not understand in:

"It's possible you used the wrong magic words (open)" if you take
words seriously.

Well maybe this time it was harder for you because your usual
sentences "This is offtopic", "This is not standard C" do not match
here.

Jun 10 '07 #10
"osmium" <r1********@comcast.netwrites:
"CBFalconer" writes:
>osmium wrote:
>><mo*********@gmail.comwrote:

Is it possible to open other files in C during main() execution.
Example, i want to open a wave file that generates a sound when
ever main() function is called.

It's possible you used the wrong magic words (open) Look up
system() in <stdlib.h>, it may be what you want..

Nonsense. Look up fopen and fclose in the standard library. Also
FILE*.

Now you've added mind reading to your vast repertoire of talents?

It seems quite plausible that he wanted to generate a sound when main was
entered. Windows has terminology which encourages such use, point at a
*data* file and you can get a menu item that says "Open", which has the
meaning "Execute the program associated with this file extension".

If *I* wanted to open a file, I can't imagine ever being so young that I
would have included the word "main" in my question. Main has nothing to do
with anything of interest. I hope the OP will make clear what he really
wanted to know.

And even if you are right, there are less obnoxious and abrasive words to
use than "nonsense" to describe your exalted conclusions.
This CBFalconer chap does seem to have a very high opinion of himself
and his not so impressive C libraries which he continually pimps.
Jun 10 '07 #11
llothar wrote:
CBFalconer <cbfalco...@yahoo.comwrote:

So what do you not understand in:

"It's possible you used the wrong magic words (open)" if you take
words seriously.

Well maybe this time it was harder for you because your usual
sentences "This is offtopic", "This is not standard C" do not match
here.
Totally meaningless. You omitted the quotations.

--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
<http://kadaitcha.cx/vista/dogsbreakfast/index.html>
cbfalconer at maineline dot net
--
Posted via a free Usenet account from http://www.teranews.com

Jun 10 '07 #12

"mohdalibaig" wrote:
Is it possible to open other files in C during main() execution.
Example, i want to open a wave file that generates a sound when ever
main() function is called.
Assuming Windows 2000 DOS prompt:

int main(void)
{
system("winamp.exe Billy-Joel.wav"); // assumes files are in path
return 0;
}

For other OSs, RTFM.

Or better yet, just buy an ipod.

If you mean, can you open a wav file in your own C program, process
it, and play it back as a sound, the answer is no. The fact that
you asked the question means you have many years of learning to do
before you advance to that level. I don't get the impression that
you're quite ready to go to work for Winamp or Sonique or Microsoft
or Apple quite yet. You'd have to learn all about the sound API for
the OS you want to write for, then spend months practicing, before
you could write fully functional audio applications.

If you really want to pursue this, ask your question in a newsgroup
for your OS. It's really an OS API question, not a C question.

--
Cheers,
Robbie Hatley
lonewolf aatt well dott com
triple-dubya dott tustinfreezone dott org
Jun 11 '07 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Hari Prasad | last post by:
Hi, I have downloaded some image files by connecting to a URL and I am trying open that image file using BrowserLauncher. I am using windows xp and the default one to open image files is windows...
5
by: PM | last post by:
Has anyone found a way to open a file exclusively where it will fail if the file is already open, i have tried the following _FileStream = new FileStream(@"C:\Data.txt", FileMode.Open,...
2
by: Piyush | last post by:
Hi, I need to print stuff on the default printer on the click of a button without opening the print box opening up. Any pointers?
7
by: balgach | last post by:
Greetings all, I have a group of rather large files (by group i mean close to 2x10^7 files, each 12-15megs) now i need information which is stored in just the last 512 bytes of each file. i...
1
by: Alfons | last post by:
Hello, I have build a program that can do file transferring between a Windows XP computer and a DOS computer via a serial port. The Windows program I have build in C++ with Visual Studio 6.0....
18
by: mollyf | last post by:
I just installed SQL Server 2005 on my PC (the developer's edition) yesterday. I have some scripts written by one of my coworkers to create some tables and stored procedures in a database that...
11
by: emailus | last post by:
I am webmaster for the domain <www.alpha1.org.au>. Not being an expert in html, I take advantage of my domain Registrant's web building tool, 'Instant Website'. This tool is provided as part of...
34
by: Alexnb | last post by:
Gerhard Häring wrote: No, it didn't work, but it gave me some interesting feedback when I ran it in the shell. Heres what it told me: Traceback (most recent call last): File...
1
navanova
by: navanova | last post by:
Greetings, I have a problem of opening ms word and excel files on my computer. The files are there for a long time. I use to open and modify them. Suddenly, when i try to open the word files, a...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.