Tuesday, July 14, 2009

How to open a file with a c program.?

Ok I tried fopen to open a file called file1.txt, but it said file1 is undeclared or something like that. What's the proper code to open a file in C (if I want to open file1.txt)?

How to open a file with a c program.?
just declare a file pointer for eg FILE* f ,then





f=fopen("drive letter:\file1.txt","mode");





mode work


"a" append can make changes at the end of file


"r" read you can just read the file cant chang in this mode


"w" write you can write any where in your file


How can I create multiple output text file in C using turbo C?

I have a text file containing number of lines (not fixed). I want to write a programme which will create separate text file containing each line. How to do this using C in Turbo C. Anybody please help me and please tell it in detail.

How can I create multiple output text file in C using turbo C?
Use the below code as a reference......





#include "stdio.h"


#include "stdlib.h"























void main( )


{


FILE *fp;


char c;


int i=1;


fp = fopen("TENLINES.TXT", "r"); // Open the file to be read





if (fp == NULL) printf("File doesn't exist\n");


else {





// perform the loop until EOF


while(!feof(fp)) {





// Read a single line.....


if(fgets(str, 126, fp)) {


printf("%s", str);


//createfile(" Call create file function from here....


................


..................








}





}











}


fclose(fp);


}








void createfile(char* filename,char* content)


{


FILE *fpwrite;





int index;


fpwrite = fopen(filename,"w"); /* open for writing */


strcpy(stuff,content);


for (index = 1; index %26lt;= 10; index++)


fprintf(fpwrite,"%s Line number %d\n", stuff, index);


fclose(fpwrite); /* close the file before ending program */


}
Reply:http://www.thescripts.com/forum/thread49...





hope this will help


Cheers:)


Compile errors in my header file? why? c++?

before in my header file i had this:


File Edit Options Buffers Tools C++ Help


#ifndef SWAP_H


#define SWAP_H


//#include %26lt;string%26gt;


//#include %26lt;iostream%26gt;


using namespace std;





void swap (string %26amp;, string %26amp;);





#endif


-------


that gave me these compile errors:


Swap.h:7: error: `string' was not declared in this scope


Swap.h:7: error: parse error before `,' token


------


now i have:


#ifndef SWAP_H


#define SWAP_H


//#include %26lt;string%26gt;


//#include %26lt;iostream%26gt;


using namespace std;





std::void swap (string %26amp;, string %26amp;);


#endif


------


Swap.h:7: error: `string' was not declared in this scope


Swap.h:7: error: parse error before `,' token


---


ALL this happens when i try to compile my Swap.cpp file.. help? wats wrong?

Compile errors in my header file? why? c++?
The compiler doesn't know what a "string" is.





uncomment the #include %26lt;string%26gt; and add


using std::string;


How to read Tiff file using C#???

I need to read a tiff file using C#, but am not getting what to do, what are steps do i need to take in .NET ( means which all dll is required to read and write and other steps).





After reading tiff file i need to trasfer the same format of tiff to TXt format.








Can any one help me... plz.............

How to read Tiff file using C#???
Read it as an array of bytes.
Reply:how to open tiff using C# Report It


wallflower

Binary Tree for searching file in c++?

I wanna write a c++ program to search inside a file and build a binary tree of all those words inside the file. Anyone can help or send me the code if you have ??





Thankx


cgsupervisor@yahoo.com

Binary Tree for searching file in c++?
Here's some code in C, but it should compile just fine


under C++ (and you can "pretty it up" with C++ method


definitions to replace the C functions if you like):





http://nob.cs.ucdavis.edu/classes/ecs030...





Also, if your problem is no more sophisticated than what


you've described, you could read the words into an array


and call qsort() in probably 20 lines of code.


I am using parser generator 2 to compile a file using C++ borland 6.?

using parser generator,when i am compiling the files with C++ borland 6,i face problem with heared and include files..and the error is:cant include %26lt;.....h%26gt; forexample..or another is:ERROR must use c++ ..or something like this.


may i kow if i should do any copy %26amp; paste files between parser and borland in include folders or..can some one help me to do the projects?i realy will be thank ful..i need to read characters from a file and define the TOKENs or lexical errors

I am using parser generator 2 to compile a file using C++ borland 6.?
Fully qualify your path names (not doc.txt, but C:\Documents and Settings\Administrator\My Documents\doc.txt). This guarantees that a "file not found" is a file that doesn't exist there.





An unsafe way around getting rid of those ERROR: Must use C++ is including (before the libraries) a #define __cplusplus line. That should work, considering that the safety responsible for that mechanism is:


#ifndef __cplusplus


#error Must use C++


#endif


What are the file read & write functions in C# ???

Actually i want to know that what are the file read %26amp; write functions in C#, like fputs(),fgets(), or fprintf(), and fscanf(); and please also mention how to open file in c# . and how to close it.......





please reply............

What are the file read %26amp; write functions in C# ???
Ok, what you're describing is C functions which the concept is expanded in C#. Several objects are used to read and write files. They include the buffered streams, file streams, text read/writers to name a few. Most fall under the system.io class or input/output class of structure. An example is demonstrated below:





using System;


using System.IO;





class FSRead


{


public static void Main()


{


//Create a file stream from an existing file.


FileInfo fi=new FileInfo("c:\\csc.txt");


FileStream fs=fi.OpenRead();





//Read 100 bytes into an array from the specified file.


int nBytes=100;


byte[] ByteArray=new byte[nBytes];


int nBytesRead=fs.Read(ByteArray, 0, nBytes);


Console.WriteLine("{0} bytes have been read from the specified file.", nBytesRead.ToString());


}


}








I've also included some links below.





Hope this helps.

hollyhock

Function for copying a file in c language?

for writing nc i should copy file from a drive and paste it in other


drive or location .what function i should use for copying a file.


and also for cuting a file.


notice:i am programing in c.

Function for copying a file in c language?
On UNIX style systems you can execute commands with the system call, for example





system("cp pathname1 pathname2")





Likewise on Windows but with copy instead of cp.





http://www.die.net/doc/linux/man/man3/sy...








Windows has a CopyFile function which can be called from C.





http://msdn.microsoft.com/library/defaul...
Reply:This is not tested and has no real error checking but should get you started.





int copy (char * src, char * dest)


{


char buf[1024];


FILE * in, *out;





in = fopen(src, "r");


if(in == NULL)


{


return(-1);


}





out = fopen(dest,"w");


if(out == NULL)


{


return(-1);


}





while(fread( buf,


sizeof(buf),


1,


in))


{


fwrite(buf,


sizeof(buf),


1,


out);


}


fclose(in);


fclose(out);


return(0);


}
Reply:Or you can have the program do it with the appropriate calls. Use C file I/O to open the file, write it to another file at the new location, close both. Then make calls to appropriate functions to delete the old files if needed. I beleive that unlink works in *nix and kill works under DOS or DOS box. You'll have to look up the Windows functions if you need it in the Win32 or Win32s APIs. I hope this helps.
Reply:DanD is quite rignt. One additional detail: you can use function "system" in DOS and Windows also.


system( "copy pathname_1 pathname_2" );


If you want to "cut" the file call then


system( "del pathname_1" ) for Windows


of


system( "rm pathname_1" ) for *NIX


Cut and Paste file from C drive to D drive?

I have a whole bunch of Sims games installed in my computer under C drive. But now my C drive is really filled to the max and my D drive has about 8GB free.





Is it possible to cut and paste the whole EA games file from C drive to D drive?

Cut and Paste file from C drive to D drive?
It might Create issues in cutting and pasting, as some files also connected to system registry and refer to original location. You start installing new files on D: drive as it instalation will give you option to decide about target folder. You can save some space in C drive by de-intalling some games or un-sed software or moving noral data(like documents, songs etc) from C to other Drive
Reply:No u can't CUT and PASTE. Instead u can re-install to your D: Drive.
Reply:Uninstall the sims, I believe it will ask you if you want to keep the saved games. Reinstall on the other drive and transfer the saved games folder.
Reply:Yes you can, you must do it in a whole folder and take patience because it my take a time to transfer a big files, after the procedure run a disk clean-up to drive C and maybe defrag it.





I hope it helps!
Reply:Try CTRL+C and CTRL+V first. Then start playing them from the D: drive. If that works, then delete from C: drive.
Reply:No, the installed game will still try to read files from their original installed location.


How can I run an exe file by C# Windows programming?

How can I run an exe file by C# Windows programming? I have problems in running an exe file by clicking the button that i made in c# windows programing, can anyone of you write the code of event handler in c# through which i can run exe file by just clicking the button,rest of the code is:


using System;


using System.Windows.Forms;


using System.Drawing;


class ButtonForm : Form {


Button MyButton = new Button();


public ButtonForm() {


Text = "Respond to a Button";


MyButton = new Button();


MyButton.Text = "Press Here";


MyButton.Location = new Point(100, 200);


// Add button event handler to list.


MyButton.Click += new EventHandler(MyButtonClick);


Controls.Add(MyButton);


}


[STAThread]


public static void Main() {


ButtonForm skel = new ButtonForm();


Application.Run(skel);


}


// Handler for MyButton.


{ Please guide me with this part.


}


}


Thank u in advance.

How can I run an exe file by C# Windows programming?
Okay, you already have a function defined, you need to go to your Form.cs file, where the EventHandler is located.





MyButton.Click += new EventHandler(MyButtonClick);





This points to the MyButtonClick function.





**************************************...


Now you need to add:





using System.Diagnostics;








Then create a process:


Process TheProcessYouNamed;





private void MyButtonClick(object sender, EventArgs e)


{


TheProcessYouNamed = Process.Start("EXEToRun.exe");








TheProcessYouNamed.CloseMainWindow();


}


File handling in C?

hi guys and gals. i've gotta submit a project. i hav to handle student details such as name, roll number,5 marks, avg,result and rank. i need to save it in a file using C. cud u plz help me gettin the codes. plz.

File handling in C?
Unless you're working with a database system (and you probably aren't), the file management is the least of your worries.





First, develop a program that handles the records in an array (or better, an STL vector or a linked list) in memory. That's where you're going to have to add records, delete records, sort records, etc. It's easier to manage it here than in a file.





Second, write code that goes through your array/list and writes each record to a file. You'll then write the opposite of that which builds a list from the file. These you'll call when your program quits and when it starts. If you want to get fancy, you might save more frequently than this in case of crashes, either on a timer or before and after sorting or other operations.





Now to the crux of your question, how to do this. That's going to depend a lot on what API you're using. In windows you'd use CreateFile and WriteFile. Using standard C or C++ with streams will give you other options.





I've added a link here to an article that goes over some of the standard C options for reading and writing files.





http://www.exforsys.com/content/view/207...
Reply:The file save fuction is differ C# then GML.





To write GML go to http://www.gamemaker.nl/download.html

cabbage

Most important file in c drive?

wat is the most important file/files in the c drive that will coz serious problems for windows to run if they are deleted by accident?

Most important file in c drive?
content of windows folder or system files like ntldr.sys....


Hi! How do I open a file in C and create one if it doesn't exist?

I have a problem with creating a file in C. I would like to open existing file (or create one if it doesn't exist) and write something into it:


/* open the file */


if ((shfd = open(argv[2], O_CREAT | O_RDWR, 0677)) %26lt; 0)


my_error("open failed");


/* map a portion of the file to buffer in memory */


if ((mem = mmap(0,SIZE,PROT_READ | PROT_WRITE, MAP_SHARED, shfd, 0)) == (void *)-1)


my_error("mmap failed");


sprintf(mem, "%d", getpid());


However, when the file doesn't exist and is created, its empty, and I get "bus error" message at the last line... If I try to write something to the file that already exists and is empty, I get the same message. If it exists and is not empty, it works fine...


Could anyone please help? I would really appreciate any help, since I don't know why I'm getting that error...





Thanks a lot for your time.

Hi! How do I open a file in C and create one if it doesn't exist?
You can't extend a file with mmap(). You can map


memory that you might write into, but when you close


or fsync the file, it will NOT be extended.





The historical way to do this is to lseek to the position


you want and write a single byte. The filesystem will


arrange that the intervening bytes will look like zeros.





I've modified your program snippet to open a file,


mmap it, and scribble in a bunch of bytes -- while


preserving whatever is there. It's not particularly


clever, but it should show most of the details you're


looking for. You can contact me through YA if you


have questions.





#include %26lt;sys/types.h%26gt;


#include %26lt;sys/stat.h%26gt;


#include %26lt;fcntl.h%26gt;


#include %26lt;sys/stat.h%26gt;


#include %26lt;unistd.h%26gt;


#include %26lt;sys/mman.h%26gt;


#include %26lt;stdio.h%26gt;


#include %26lt;string.h%26gt;


#include %26lt;stdlib.h%26gt;





int


main(int argc, char* argv[])


{


  int shfd;


  struct stat statbuff;


  char *filename = argc%26gt;1 ? argv[1]   : "testfile";


  int mmapsize = argc%26gt;2 ? atoi(argv[2]) : 100000;


  char *mem;





  /* open the file */


  if ((shfd = open(filename, O_CREAT | O_RDWR, 0677)) %26lt; 0)


    perror("open failed"), exit(-1);





  /* if it is too small, we will extend the file for the mmap */


  if (fstat(shfd, %26amp;statbuff) != 0)


    perror("stat"), exit(-1);


  if (statbuff.st_size %26lt; mmapsize) {


    if (lseek(shfd, mmapsize-1, SEEK_SET) == (off_t)-1)


      perror("lseek"), exit(-1);


    if (write(shfd, "\0", 1) %26lt; 0)


      perror("write"), exit(-1);


  }





  /* map a portion of the file to buffer in memory */


  if ((mem = mmap(0, mmapsize, PROT_READ | PROT_WRITE, MAP_SHARED, shfd, 0)) == MAP_FAILED)


    perror("mmap failed"), exit(-1);





  /* scribble on the file *after* whatever was already there */


  if (statbuff.st_size %26lt; mmapsize)


    memset(mem+statbuff.st_size, 'X', mmapsize-statbuff.st_size);





  if (close(shfd) %26lt; 0)


    perror("close"), exit(-1);





  return 0;


}
Reply:Hmmm, I dont follow how you are trying to do it but this is how I always do it.





void main()


{


FILE *Pfile;


char FileName[] = "nameoffile";


char buffer[];





//open file or create if it doesnt exsist


Pfile = fopen(FileName, "w"); // w = open for write


// r = open for read


// wb = open binary for write


//fill buffer with what you want to write to file


strcat(buffer, "stuff you want to add to file");


//write buffer to the file


fwrite(%26amp;buffer, strlen(buffer), 1, Pfile);


//DONT forget to close the file when done!!


fclose(Pfile);


}


Reading data from file using C++?

I have a text file representing time-voltage signal 2 colums of numbers, in scientific format eg.


time voltage


0.003 1.553e-8


... ...





how do I read them into a mx2 matrix using C++?





used to working with C, not familar with C++

Reading data from file using C++?
You could use class ifstream.


It makes very easy to read from a file as an input stream.
Reply:If you are not required to use the C++ library, then use the C one. I always preferred the C one. Even in my college courses, where we were expected to use C++ I was not penalized for using the standard C library. If you are going to school, you might want to double check if this is acceptable. IMO the C++ standard library using too confusing and abstracted of a syntax to be understandable. Plus I knew how to look at standard C code on paper and determine what the result would be, in C++ I wasn't and still can't always do this.


Do I need to file Schedule C?

I started the business in 2006 and claimed a loss of the business income and filed a Schedule C for 2006.But, I only participated passively(less than 500 hours) in my business for 2007. I did not sell any inventory nor did I buy anymore. I used some items from the inventory for personal use. I did not have any expenses for 2007. I plan to close the business this year 2008. Do i need to file a Schedule C for 2007 and if so what line items would i need to file out?





Appreciate any help.

Do I need to file Schedule C?
I'm not sure but you do have to claim your inventory if you did not close the business prior to 2007 even if you did not sell any inventory. It is still considered an asset. I would consult with an accountant on this.
Reply:If you were in possession on inventory that you did not sell, can you not write off the depreciation?
Reply:its sounds like no you do not if you had no expenses cant see what you would fill out

phlox

How to use java file in c#?

Hai all,





I have one doubt in c#.


I have few files in java.


Can i use those java file in c#.





For example DataSheet is a class in java.


Can i use that DataSheet class in my windows application.





But that java file is opened like J#.





Then i have another doubt. What is language interoperability.


Any relation is between language interoperability and the above case.





Any one please guide.





Thanks advance

How to use java file in c#?
Use Java in C# using IVKM.NET (http://www.codeproject.com/useritems/csh...


Or this http://www.thescripts.com/forum/post1025...





Language interoperability is the ability of code to interact with code that is written using a different programming language. Language interoperability can help maximize code reuse and, therefore, improve the efficiency of the development process.





Yes, language interoperability is demonstrated in this case. See http://www.velocityreviews.com/forums/t1... for more details on how C# and Java interoperate with examples,


How can I delete a .exe file that has secretly been installed in my C: drive?

After visiting a website ZoneAlarm notified me that a .exe file in my C: drive was trying to access the internet. I know this is a foreign file b/c I never installed anything like that and nothing like that was ever there. Norton has not been able to quarantine the file b/c a message says the file is in use or write protected. I cannot delete the file for the same message. What can I do? This file is repeatedly trying to access the internet. I'm suspecting it's a malicious file.

How can I delete a .exe file that has secretly been installed in my C: drive?
Probably easiest to boot the system in safe mode (tap F8 every second or two while booting until you see the screen giving you the option to boot into safe mode). Once there, you can probably delete the file without any problems.





Failing that, try downloading Knoppix (http://www.knoppix.com). Boot off of that, and you'll definitely have the ability to delete it.





To make an effort to prevent this activity in the future, try downloading a free realtime spy/malware monitoring tool such as Windows Defender.
Reply:I had the same problem before - I honestly can't remember how I fixed it now but I would suggest you go into your task manager (ctrl-alt-del) and google each of your processes that you're not sure about - you should pick up a website that will have most of them and you can just search in there.





End any suspicious processes (the website will usually suggest whether it is recommended to end certain processes or not) and go back to the file you want to delete and try deleting it before it starts itself again.





Even if this doesn't solve your problems (there are some better solutions above), you should clear some of your ram and the pc will run faster.
Reply:write down the file name ... then click start and go to find or search, click on all files and folders then type in the file name.. let it search then right click any and all files one at a time and delete them empty your recycle bin and then rerun you virus and malwear protection
Reply:Put it on a different folder to the one it is on, and then quickly delete that folder.


If that doesn't work, you will have to boot in Safe Mode, run antivirus and antispyware software, and if the file is still there, delete it.


http://www.pchell.com/support/safemode.s...


Can I move Norton Anitivirus definition file in C:\Program Files\Common Files\Symantec Shared\Virus Defs to D:

I am using Norton Internet Security 2004 together with Norton Anitfvirus on Windows 2000 plarform. The virus definition file is growing almost everyday at speed of 50MB/day. Now the file size is 5000MB (5GB) but I am using Windows 2000 FAT32 file system. My C partition can only extend to 7.8GB. Now C partition has 400MB free space left only and is approaching risk limit . However I still have 6GB in my D partition.

Can I move Norton Anitivirus definition file in C:\Program Files\Common Files\Symantec Shared\Virus Defs to D:
Moving the virus definitions would break Norton.





Seriously, and I know you didn't want to hear this, it would greatly benefit you to dump Norton and use a different antivirus software. Norton is recognized rather widely by techs to be inefective.





A good free one (I use the paid version) is www.free-av.com, which is Avira AntiVIR. This is the best anti-virus I have ever come across, and I've test-driven many.





Good luck!


Can i take emage file of C & D drive which is carry on C= windows 98 se and D=windows XP Pro SP-2 Pl send prg.

I have four partition CDEF. C for win 98 se %26amp; D for win XP sp2.


E, F for data storage. Now i wnat to take a sing file as mirror ro emage file off both drive C %26amp; D. Pl if some one have any prog which is fullfill above facilities send me by mail in zip format. OR guide me Please Help me.......

Can i take emage file of C %26amp; D drive which is carry on C= windows 98 se and D=windows XP Pro SP-2 Pl send prg.
Can you access win 98 from xp if so bring the firle too the desktop of xp and go from there.

verbena

Do I file 2 schedule C forms if I have 2 businesses, if so how do I combine the figures from both?

I have 2 businesses. One is my main business and one is a side business. I usually file scedule C for each of them however since one of these businesses has not done any sales in previous years this was never an issue. Last year one of my businesses had a slight loss and the other one made profit. I am not totally sure what to do next. I think I am supposed to file 2 different schedule C forms and then somehow combine figures but I am not totally sure. Any suggestions? Detailed suggestions would be helpful.

Do I file 2 schedule C forms if I have 2 businesses, if so how do I combine the figures from both?
you have it exactly correct; do two separate Schedule Cs and then add the net income figures together before you go on to Schedule SE
Reply:Yes, two schedule C forms, but add up the numbers from the end to go on one schedule SE and one form 1040.





Example: if one made $8000 and the other lost $500, the total would be $7500 and that would go on top of the schedule SE and onto the 1040.
Reply:When you own an unincorporated small business by yourself, the IRS considers you a sole proprietor. Your business earnings (or losses) are included as part of your individual income tax filing.





If you run two or more sole proprietorships, you must file a Schedule C for each.





You would "net out" the profit/loss from the two to enter on your form 1040.
Reply:You are correct that 2 Schedule Cs would be completed. The combined total profit/loss would go on page 1 of your 1040.


No 1099? Do I file a schedule C?

Have main job and side business--unrelated. Filed schedule C for past 2 years on side income earned (under 10K). in 2007 no money made in side business but have contract--do I file a schedule C this year or for next year after am I paid? If so, what do I do about my business deductions this year--do I carry them over to the next year and not file a schedule C this year because my side business made no money?

No 1099? Do I file a schedule C?
file schedule C for 2007. you lost money -- no revenue but had expenses. this negative carries over onto your Form 1040 and reduces your tax due





IRS trusts that you'll make this all back in the future and thus pay the taxes then.





[as long as you make money at least 3 years out of every five they do.]
Reply:Do what "Spock" says he's right on.





Save me some trouble, lol


Help with Opening file in C.?

Im having a problem here. I have a little project to do but having some problems. The question simply asks me to prompt the user for a filename. after i get that i need to open the file and read in the information line by line and add the values of some numbers.





This is what I have





#define MAX 30


FILE *ifp;





int main(){





int num;





int scores;


char filename[MAX],c;





printf("Please enter filename to open\n");


scanf("%s",%26amp;filename);





ifp = fopen("filename","r");





fscanf(ifp,"%d",%26amp;num);





while(num!=0)


{





fscanf(ifp, "%d",%26amp;scores);


scores+=scores;


}


printf("scores are: %d\n",scores);











fclose(ifp);








return 0;


}








everytime i try it it shows 0 when printed out onscreen. the file i have only have the number below in that order.





500


345


323

Help with Opening file in C.?
scanf(%s, filename); // yah, you can remove the %26amp;





ifp=fopen(filename,"r"); // remove quotes from filename





fscanf(ifp,"%d",%26amp;num); // if the first num is 500 in your file, you will spin in the loop forever, i.e.





while(num!=0) // no way to get out of this since num == 500
Reply:You should remove the %26amp; character *only* from:


scanf("%s",%26amp;filename);





The while loop will go forever, since you read into num only one time and then it never gets modified.





Replace it with this loop:


while(num!=0)


{


scores+=num;


fscanf(ifp, "%d",%26amp;num);


}


So you keep reading into num, but adding its value to scores, which you have to initialize to 0, so the nums don't get added to some random value that scores may have upon declaration.


int scores = 0;





Oh, and you should read a new num, after you have added the first num read before entering the loop, otherwise you will lose the first value.





That should work. Good luck!





LATER EDIT: check back since I did some mistakes myself!
Reply:You should use


scanf("%s",filename);





You don't need the "%26amp;" because it is already a pointer.





Any array is already a pointer and char is no exception.





I don't see any other problems in there except that you should check ifp after you do the fopen and if it is null then warn that the file was not opened.


Reading integers from FILE in C?

I have a file that has integers on one line diveded by one space and nothing else.


For ex:


6 23 -2 45 -11





I have to do more things with these numbers, find the sequence with the maximum sum and others. But that's not the problem, I can do that. The problem is reading these numbers as integers and not as strings. I've tried reading them as strings and then using atoi() but I get a warning about atoi: "passing arg 1 of atoi makes pointer from integer without cast" - something like that.


My declaration is char b[1000]; char c. c is the variable in which I read characters from the file with getc(). If I declare them as char *b, *c, I don't get any more warning for atoi() but reading from the file doesn't work anymore.


Any suggestions?

Reading integers from FILE in C?
Have you tried looping (until end-of-line or EOF) using fscanf? This function is used like fprintf/printf. So,


FILE *filePointer;


int myInt;





/* Open the filePointer...blah blah blah */





/* Read an integer into myInt */


fscanf(filePointer, "%d", %26amp;myInt);





No atoi conversion is needed in this case...it's already an int. The getc function will only retrieve one character at a time. For example, 23 would be read as 2 and then 3. Alternatively, you could read like this, entering each character into a char array until you hit a space and then, after adding a null-string char ("\0") send this into atoi.

snapdragon2

How to read Tiff file using C++ or C#?

Hi





am working on OCR in TIFF using C++ and C#, but am not able to open an tiff file Programmatically. i have downloaded libtiff library from libtiff website , but in Visual Studio C++ it is shownig link error as LINK : fatal error LNK1104: cannot open file "dlibtiff.lib".





Can any one suggest me what to do???





plz send me the dlibtiff.lib file to me





Am waiting for replay....





Plz help me ......

How to read Tiff file using C++ or C#?
- When you say you downloaded libtiff, did you actually build the source to get a static library?





- If you do have the binary built, did you mention the library in the linker settings? And the library path?
Reply:Hi i have builded and linker is also set but still showing LINK : fatal error LNK1104: cannot open file "libtiff.lib", can any one help me. Report It



How to make a C program run a bat file using cmd.exe?

I made a C program that uses simple file handling and types some command in a bat file. Then It runs the bat file using 'system' statement in 'process.h' . The problem is it runs in NTVDM ie suppose if i give the command to run a file in C:\asdfasdfadf.txt, it uses only the eight character of the file name. The batch file works perfectly when run in cmd.exe. Is there any way to start the bat file in cmd using a C program

How to make a C program run a bat file using cmd.exe?
So I guess you're trying to make a DOS program access files with long filenames, right?





Well, I've never tried it, but maybe you can try putting the file name in quotes.


For example, if you want to open a file called


Hello Out There.txt, you would pass this string to your 'open file' C procedure:


"Hello Out There.txt"





My suggestion comes from the fact that if you run command.com and you want to use EDIT.COM to edit a text file with a long filename, you need to put the file name in quotes. Keep in mind that command.com is a DOS program, while cmd.exe is a Windows console program. Cmd.exe allows long file names, while command.com expects 8.3 format.





Another suggestion is to pass the C 'open file' function the mangled 8.3 DOS name that Windows uses for files that use long file names.


The mangled name for Hello Out There.txt would be helloo~1.txt. To get an idea about how the mangled names work, just run command.com and look at all the file names and directory names which use long file names.
Reply:#include %26lt;stdlib.h%26gt;


int main(void){


system("cmd.exe batch_file_name.bat");


return 0;


}
Reply:I haven't done much C in Windows, but you might try fork, and exec the command in the child process. Just a suggestion of a different method, I have no idea if it will make any difference.
Reply:Gopinath M This link might help you understand





http://www.google.co.uk/search?hl=en%26amp;q=m...


C drive disk space differ from actual file size in c drive?

when i cright click on c dribve and see proporties it shows total size 27.8 gb and free space 1,85 gb


when i enter c drive select all files in c drive and then right click and see proporties actual file size is=4.21 GB





why so and even cant defragment as it says minimum 155 free disk space required


why so happening can anyone help

C drive disk space differ from actual file size in c drive?
Some files are "hidden". click tools, view, show hidden files and folder. i use it hide files =)
Reply:Some files are hidden and they aren't counted when you click properties inside the C drive. Also when u see the C drive properties it doesn't show the space windows occupies
Reply:microsoft and the drive manufacurers use a different numbering system to measure the drive space.pay attention to the highest amount
Reply:When you right click and go to properties it is going to give you a more accurate reading than if you try to select all and go to properties. As mentioned, there are hidden files, and if the difference is as large as you say (27.8GB versus 4.21GB) you're definately not finding something on the disk.





27.8 with 1.85GB free sounds about accurate for a 30GB hardrive. If you have music, videos, or pictures, that space will go fast.





In order to defragment you need to delete some files and free up some disk space. The defgragmentation tool requires a certain amount of free space to move files to, so it can better organize the drive.





Try deleting extra stuff and removing programs that you do not use. You should be able to free up enough disk space to run a defragment. If you're system is running very slowly, it's not all that surprising considering it sounds like your hard drive is almost full.





A good option is to buy an external hard drive, and use it for storage. Not to mention you can transfer all of the stuff you need to the external and format and then reinstall windows....which will make your computer seem like new. Make sure you have all of your driver disks (The software for things like video cards, sound cards, and so on), or have someone on hand who knows about formatting and reinstalling windows, since the "driver hunt" can be a pain in the ***.





Good luck!


C++ - How do i read/write text file in C++ programming??

Hi,





I was wondering if any programmers can help me out.





I am currently a student who is required to do a small project.


and one of the requirements is to read/write text file using C++ programming.








so, was wondering if anyone can help me out here....








is it possible for me to read in the text file and store every word in a array?








Like if my text file contains ::





John 14 Student


Peter 26 Engineer


Tom 20 Teacher








and i want to store them in the program like::





name[0]=john


age[0]=14


job[0]=Student





name[1]=Peter


age[1]=26


job[1]=Engineer





name[2]=Tom


age[2]=20


job[2]=Teacher








and to write them back into the text file...





haha is it possible??





hope someone can help ^^





thanks





-Oleo

C++ - How do i read/write text file in C++ programming??
Yes, its very possible. First you need to #include %26lt;fstream%26gt;


then declare an input and output file object like this





ifstream = inputFile; //input file


ofstream = outputFile; //output file





//declare the path of the file to be read


inputFile.open("%26lt;complete path to file%26gt;"); //path c:\text.txt


outputFile.open("%26lt;complete path to file%26gt;");





//then to read from the input file





inputFile %26gt;%26gt; //any variable can be put here, the inputFile %26gt;%26gt; works just like the cin %26gt;%26gt;





//then you can write back to the output file the same way





outputFile %26lt;%26lt; //whatever you want to output, it works just like cout %26lt;%26lt;





//of course this is just pseudo code but you could easily make it work with arrays by adding a for loop. for easier debugging, write the program first with all cin %26gt;%26gt; and cout %26lt;%26lt; statements. once it works that way, replace all the cin %26gt;%26gt; with intputFile %26gt;%26gt; and cout %26lt;%26lt; with outputFile %26lt;%26lt;





//one last thing make sure to close both files when you are done with them





inputFile.close();


outputFile.close();





//its just that simple! happy coding.
Reply:Surely, you can use C++ streams: operators '%26gt;%26gt;' and '%26lt;%26lt;' to write to and read from the file.


Though i write in C++ for a long time, for file input/output i still prefer good old plain C read/write and fscanf/fprintf. You can use any of these two pairs with the same result.

avender

File handling in C: How to edit existing Binary File(Not Append)?

Any one PLS Help Me!! (Urgent)





I want to edit the contents of a structure I've written to a file(Turbo C). And I have to save it too. PLS help me out..........





The purpose is 'edit' option in a phone book application in Turbo C.

File handling in C: How to edit existing Binary File(Not Append)?
A phone book application should have a database-like structure. You'll be writing to offsets and only certain amounts of data that fit the field sizes. At least, if you're writing data to the structure. If you're changing the structure best is to create a new file with that structure and copy the data over, deleting the old file.
Reply:you can use fseek() to go to a certain position in the file, and then fwrite() to write a record.





you have to calculate the position in fseek; if your file only has structures which have the same file, it's easy. then the position is sizeof(structure) * index.
Reply:The Binary/Text file dichotomy is Windows-specific, meaning that other operating systems just have you open the file, perform functions on it and close it and it doesn't matter what type of file it is. Even in Windows, the difference is not as important as understanding what is in either file.





Obviously you want to search for the proper struct, copy it to memory edit it and rewrite it. The first thing to do is to find the struct. If you know the size of the struct (which you should) and the number of the record you should be able to determine its position in the file. If you have to find the record, you can search for the relevant information however you choose, copy the file position of the start of the struct into a separate variable, copy the struct into a copy in memory, and so on, resetting the position of the file pointer to that of the variable you saved the start position into.





Frankly, you might as well just copy the whole database into memory, into an array if you can't deal with linked lists and other data structures, edit it, and write the whole file back to disk destructively. But if that's how they want you to do it that's how you should do it.


Calling a batch file in C++ script?

How Do i Call to a batch file named open.bat in a C++ script





How do i tell it to call a batch file from the following script:





#include %26lt;iostream%26gt;


using namespace std;





int main ()


{


cout %26lt;%26lt; "Hello\n ";


cout %26lt;%26lt; "\nTestingSomething\n";


cout %26lt;%26lt; "\nI hope this works\n";


cout %26lt;%26lt; "\nIm going to launch a batch file\n\n";





return 0;


}








I want to see what the script looks like after you've told it to add the batch file.





Show me what the script will look like after the calling of the batch file is added.

Calling a batch file in C++ script?
you probably want to call system()





http://www.cplusplus.com/reference/clibr...


Function prototype in seperate file , 3 file help c++?

Hey


I've got a c++ query. Ive got currently 2 files. One is the main , whilst the other file is a seperate bool function, which is used by the main file when running the program.


I want to create another file (ie : fun.h) which stores the prototype of the bool function.


What do i have to write in each file, so all 3 files connect to each other, and so that when all 3 files compiled together, no syntax errors occur.





thankyou :-)


C code help for file output?

I have a problem with the following code .....





FILE* out_file;


out_file = fopen("c:\\data.dat", "w");


double data = 0.017876148;


.....


fprintf(out_file,"%lf", data);


fclose(out_file)





I want to print out the exact 9 digits on a dat/txt file but I am getting a truncated digit of 0.0178761. How can I fprintf the whole data without being truncated ?

C code help for file output?
with the printf field modifier, like so ...





fprintf(out_file,"%.9lf", data);








see the '.9' ? that says to use nine digits of precision after the floating point....good luck








Man I love C. Hope you can enjoy it too. It's a steep learning curve at first, but very powerful lang and worth the work. Can't tell you how many languages borrowed and stole C ideas and structure. My point: learning C will aid leaning across many languages...no time is spent on it is lost, so to speak.
Reply:Anytime, like to help. Very welcome.... Report It


violet

Microsoft visual c++, message appear saying:program: c:program file?

program c:program files internet explorer


this application has requested the runtime to terminate it in an unusual way,please contact the application support team for more information


what i can do?

Microsoft visual c++, message appear saying:program: c:program file?
Either the Visual C++ is corrupted or the installation cd is missing files, reinstall it.


If the installation Cd is working fine on another PC, then ur Windows is corrupt or another application is conflicting with Visual C++


How to file W2-C along with W2 ?

Hi,





For 2007, I had by mistake been taxed for 5 months for state Indiana instead of NJ. Also the W2 showed the same and because of that I got 2 W2 from my employer. I have never worked or been to Indiana.





When I reported the error to them they have sent me a W2-C. I have not yet filed my tax. I wanted to know how should I go ahead with filing my tax. Can I file the entire 12 months for NJ since I have already got the W2-C. Or do I have to file for both states.





Also I think the federal tax filing should not be affected by this since only the state tax withheld was wrong. Please let me know your opinions on both my questions.





Thanks,


K Sri

How to file W2-C along with W2 ?
Your right your fed tax wont change and you would only have to file the corrected W2c with the correct state.


I have problem in programming! pls answer this..It is .c file extension?

how do I make a program that never goes down even if i press enter? it will remain only on the same line.


EXAMPLE of my program:


#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;


int main()


{


int major,minor,line,line1,units,sUnit;


float grades,wpa,msca,grade1,sum,average,avera...


char another='Y';


printf("Press Enter to Start...\2\n");


scanf("%c",%26amp;another);


system ("cls");


printf("\nHow many major subjects you have: ");


scanf("%d",%26amp;major);


printf("Supply equivalent grade and unit for the major subjects:\n\n");


printf(" GRADES UNITS\n");/* after I key in the grade it must not go down


even if I press ENTER, it must be in the same line*/


for(line=1; line%26lt;=major;line++)


{


printf("(%d) Major subjects:\t ",line);


scanf("%f",%26amp;grades);


printf("\t");


scanf("%d",%26amp;units);


}


getch();


return 0;


}








\\try to paste this on your program.

I have problem in programming! pls answer this..It is .c file extension?
the line will move down because of "echo" on the terminal





best way is to output ANSI terminal escape codes to move the cursor back up to the previous line





for reference:





ESC = ASCII#(27)





printf("\033[1A") moves the cursor up a line on most termninals


Leaving out a vowels in C++ file?

Can anybody help me??? What i need to do is to leave out the vowels in ac++ file.

Leaving out a vowels in C++ file?
Interesting question... I assume you want to parse C++, and remove the vowels on user identifiers (eg. "shrouding" the source itself).





Is this what you are after? Or do you simply want a filter to remove vowels from anything...





If the second is what you want, try something like (note, no real C++ features used, aren't needed)





#include %26lt;strings.h%26gt;


#include %26lt;stdio.h%26gt;





int main()


{


int c;


while ((c = getchar()) != EOF) {


if (index("aeiouAEIOU", c)) {


putchar(c);


}


}


return 0;


}





would do it. If you want to shroud C++ source, the project is a bit (understatement) bigger -- start with a BNF description of C++, and look at SNOBOL4 (www.snobol4.org). SNOBOL4 will accept the BNF description (more or less) directly, and will let you modify the user variables (function names, etc.) as they are seen. My estimate -- it will take 1 to 2 months to write the thing. Alternatively, look for "C++ source shroud" on google -- that gave my www.abxsoft.com as a possible source for this program.
Reply:just write a function








void no_vowels(std::string%26amp; full_string){





std::string result;





for(std::string::iterator back = full_string.rbegin();back != full_string.begin(); --back){





if(*front != "A" || *front != "a" || *front != "E" ...ect){





result += *back;





};











full_string = %26amp;result;


};











that will do it for strings....i think....its the gist of it i think you need to start at the back of the string, and cuz _ += will add it to the front....i could be wrong, assuming u know file IO that shouldn't be too bad....u can make it return a string pretty easily too
Reply:I don't understand...can you explain
Reply:What is a C++ file?





I suspect you are supposed to write C++ code remove all the vowels from some text, then output the remaining characters it to a file. Correct?





You will need to look at every character in the text, determine if it is a vowel, then decide whether you will write it or skip it. Try writing a function bool IsVowel(char c ), then write code that determines if 'c' is a vowel. Don't forget that vowels can be upper or lower case. Think about using a switch statement here.

peony

Including audio in a C++ file??

can any1 write me a simple code for including(importing or watever) a .wav or any odr format sound file and play it on d running of d program automatically??? pls help urgently

Including audio in a C++ file??
What you can do is issue a call to MCI to handle the audio file.
Reply:Uh, for which operating system? If it's DOS, then you have to search for pre-built libraries for sound and music, then run your program in DOS BOX (DOS emulator program). Back then, you had to program sound cards directly and build you own sound/music engines if you didn't want to purchase one.





For Windows, if you're using a framework like Borland's VCL or Microsoft's MFC, then you'll have to look in your framework's reference files to find the sound/music playing functions.


If you're programming with the Windows API, you can use different multimedia functions. For playing .wav files, you can use the sndPlaySound() function. For simple playback of .wav %26amp; other types of sound/music files, you can either use the MCI or DirectShow functions. MCI is older and most people use DirectShow nowadays, but MCI is simpler to use.





Example of mciSendString() function to play a MIDI file:


mciSendString( "play c:\midi\myfile.mid",0 ,0, 0);


http://msdn2.microsoft.com/en-us/library...


How can I run a c file "copylru.c" in the vc++ 2005 express edition?Plz tell the menu how to buuild and run.

I have a program copylru.c.How can I run it in the vc++ 2005 express edition?Please explain me the menu how to build and run the same

How can I run a c file "copylru.c" in the vc++ 2005 express edition?Plz tell the menu how to buuild and run.
My 2005 edition doesn't have a "Run" command. It's a "Debug" command which does the same thing. Look towards the top and you'll see a small green triangular play button to execute the debug. Hope this is what you were asking.


How to include *.c file in a C program?

note that the compiler used is TURBO C++

How to include *.c file in a C program?
All the files are included in the same way.


For example you can write it as





#include "file1.h"


#include "file2.c"


#include "file3.c"


.


You can't write " *.c ".....you have to mention all the file names separately in the program !!
Reply:I don't think there is a direct way to do this.





U can create a intermediate header file called allfiles.h which inturn


includes all the necassary C files. Your program can just use the %26lt;allfiles.h%26gt;





The allfiles.h can be generated thru another program(may be a batch file) to avoid manual effort


How do zip my C++ file to be under 250kb?

Our kb size of our compressed zipped folder is way over the limit that I want (at a whopping 1,000+ kb!). We have done everything said in the instructions but it still doesn't work. The only solution we see is to remove the debug folder before zipping and that will do it, but doing this causes our FormApp program to be unable to execute because of the missing debug file. Is there something we should delete in the debug file or something else we should be doing? Please email me back.





email at pyrojelli@yahoo.ca if you can help me and I will email my file to you, thank you all.

How do zip my C++ file to be under 250kb?
http://books.google.com/books?q=c%2B%2B+...

long stem roses

Adding An Icon To a C++ File?

I wrote a file in Visual Studio 2008 it was a win32 project, and empty.





How Can i add an icon (.ico) to the .exe file i compiled?





I alrdy have an .ico file.





Thanks in advance.

Adding An Icon To a C++ File?
Move your .ico file into the \res folder of your project.





Open the resource viewer. Right click on your project (or open the icon folder). Add item, existing item, pull down the extension so ".ico" or "*" is selected. Click on your .ico file.





It is now added to your project. Hope that helps.


How can we find a good attorney in Washington, D.C. to file a writ of mandamus against Sec. of State Rice?

Due to various unique historical, legal, etc. criteria, we have a group of people here who have determined that they should qualify for the issuance of "US national non-citizen passports." (The issuance of such passports, and general qualifying criteria are outlined in Dept. of State Foreign Affairs Manuals, Series 7.)





Here where we live in Asia, however, the local United States embassy/consulate refuses to accept the applications (which is form DS-11). They also refuse to give us any paperwork regarding their "opinion" and their "non-action." We are tired of trying to argue with the consular officials. A law student from the USA suggested that we need is to file a writ of mandamus against the Secretary of State in the appropriate court in Washington, D.C.





Our own background research on this subject is actually quite extensive. But how could we find a suitable attorney? We do not live in the USA.





What would this cost? We definitely want to raise the money.

How can we find a good attorney in Washington, D.C. to file a writ of mandamus against Sec. of State Rice?
Sounds like BS to me, 'mandamus' means 'we command' and frankly part of the reason that immigraiton's such a mess is that people are getting so damn pushy and demanding. I fully believe we should pull the plug on ALL immigration for 5 years, or until the whole mess sorts itself out. And, furthermore, what the hell is a US national non-citizen? Sounds like more lawyerese to me, you're either a citizen, or you aren't. Speaking OF lawyers, I think we have them to thank for the broad confusion on the issue.


When fish get spooked, they swim really really fast, which has the added effect of muddying the waters in a shallow area.


There's a lot of deliberately muddied water on the immigration question, now we've got people apparently trying to sue their way into the United States. This is all getting very very stupid...
Reply:i agree to disagree to agree.


either way, can u give me 10 points? thanks
Reply:Good luck, because you'll need it. I have the feeling that no American attorney will go up against the Bush administration. However, You might check with film maker Michael Moore, who has a web site and/ or the ACLU. It would probably cost you plenty. What other legal options might you have?
Reply:Try the yellow pages
Reply:Give it up. You can't touch her.


Simple C++ File I/O Question?

Why exactly does this program not work? I want the output to be 150


999





(Ignore the spaces/line breaks, i just want those two numbers)








I have commented the purpose of each of the four seperate peices of my code. All im trying to do here is put the number 150 into a file, then take it out and display it. that works. then, i want to overwrite 150 with 999. i know that works because i can open the file and look in it, it does indeed say 999.





the trouble starts when i try to copy the 999 and display it...i get the original junk that was in the variable 'number2'





(the code is in details because its too much text)

Simple C++ File I/O Question?
This really does seem perplexing. I am not an expert - the only thing I can think of is that it has something to do with the fact that it only takes 1 byte to represent 150 and it takes 2 bytes to represent 999. How do you know that what you are getting is what is in the variable number2 originally? I would be interested to know if instead of using 999 you used another number, like 127.


What c++ and c file extension?

example for c++ --%26gt; test.cpp





are "printf" and "scanf" commands in C++ or C

What c++ and c file extension?
c++ file name extention is .cpp


c file name extention is .c





printf and scanf commands belong to language C
Reply:The file extension in C is .c like test.c and


in C++, the extension of file is .cpp, like test.cpp.





The printf and scanf are the standard output and input commands in C. But these can be valid in C++.


The same commands are cout and cin objects respectively in C++.
Reply:The are in C++ ..





Thats a guess...





ok.


.


bye...
Reply:for c : myfile.c


forc++ : myfile.cpp


for using "printf" and "scanf" commands in C : #include %26lt;stdio.h%26gt; befor main
Reply:I'm sorry iyiogrenci but printf and scanf are also in C++ language!they are predefined with %26lt;stdio.h%26gt;;


scanf allow you to insert data from file like "file%26gt;%26gt;x" for %26lt;fstream.h%26gt; and printf allow you to print data into file like "file%26lt;%26lt;x"


for %26lt;fstream.h%26gt;

gifts

C++ file monitor?

what library and function would i use to detect size change and possibly content change of a running file?

C++ file monitor?
You mention linux compatible. However you are writing for linux only then you can look at "inotify". It's system call and you need a kernel beyond, if I recall, 2.6.12. Check you kernel version and do a web search for inotify if it isn't already in your man pages.
Reply:I think you want FAM, the File Alteration Monitor





http://oss.sgi.com/projects/fam/faq.html...





For windows an OS X you have to use different libraries - there's no cross-platform solution I know of.


C File I/O question.?

okay.. I've learned to take the content of a file and output it with printf... now I need someone to explain to me how i would set each line into a global variable. As sort of a configuration file.





like this.








file - bot.conf





BotNick "nicknamehere"


BotUser "botuserhere"





and it would set those into a variable to be used by the entire programme.





Also, if it's not too difficult, i'd like to have support for shell style comments.

C File I/O question.?
Declare the global variables *before* any of your routines, so their scope is the entire source file:





#include ...





char globNick[256];


char globUser[256];





...





int grabGlobal() {


/* In here, you assign to the global variables. */


}





int main () {


}





If your global variables get used in any other files, you declare them similarly at the top of the file:





extern char nickGlob[256];





Shell-style comments depend on your shell: look up the comment syntax. For most UNIX-based shells, it's simply "# " (sharp - space) at the start of the line.





Does that help?

innia

Source code that can expand macros in C source file?

Does any body have code that can expand macros in C source file.

Source code that can expand macros in C source file?
jonny try this link





http://www.google.co.uk/search?hl=en%26amp;q=S...


What is graphic functions header file in Microsoft Visual C++ 6.0?

In a C++ Source File program that runs in DOS, what header file contains graphic functions such as _setpixel(),





_setvideomode(), _lineto(), …? What is it's path and name?





Thanks.

What is graphic functions header file in Microsoft Visual C++ 6.0?
If your code will work purely in DOS mode (no Windows at all) you can get to a graphics mode using DOs Interrupts to set mode which defines the resolution and color depth (in DOS there is no wayb to use high resolutions with out using compatible VESA drivers for your video card) then can put pixels just by directly writting to memory locations segment b800h and a000h point to video adapters video buffer.





If you are using Windows you can use GDI.h (Graphics Device Interface) for a standardized video API independent of video driver. You use device contexts to access the graphic functions.





Loren Soth


Sunday, July 12, 2009

Please tell me whats wrong with the C header file i created ?

i am trying to creat a C header file. i want a funcion that prints a menu, prompt for the choice, scan it and return it to function main. so i created header file and tried to use the function in a program but not working pls tell me whats wrong here.





header file................





int menu_bread()


{


int choice;


printf("1.Baguette : 2.Foccacia : 3.Ciabatte");


printf("\nbread type:");


scanf("%d",choice);


return choice;


}








main function i ivoked the function ............





#include%26lt;stdio.h%26gt;


#include%26lt;program.h%26gt;





main()


{


int choice


choice=menu_bread();


if(choice==1)


printf("ok");


}











program.h is the header file i created.

Please tell me whats wrong with the C header file i created ?
I understand you are trying to do some thing. I dont want to go deap into this. All the best!





The error is due to the missing '%26amp;' before the 'choice' in the "scanf("%d",choice);" statement in the menu_bread() function.





Also make sure you place your header file (say) in the correct path. First try to have the function in the main *.c file and test. Then you move that as a seperate file. You will be able to debug easily. Hope this helps.





Please note only when you press '1' you will get the output in the console or else noting will be there. So you may like to add an else statement saying something to make sure it works or not. Please add a getche(); or getch() at the end of the program too.
Reply:don't forget that the header file always just contains the declaration of the function, not the function body:





header file:





extern int menu_bread();





C file:


int menu_bread()


{


...


}





(in your case, it also works if your header file contains the function body, but this is an exception and absolutely not recommended because it will give you a lot of trouble in bigger projects).


How to use a c++ exe file from linux in windows?

I have a c++ code in linux. In this code I call another code and I run it. The exe file for this other code is called "voronoi" and I need to give it as input "b.txt". The output will be called HEXAGON.txt . For this I use the command:





system("/.voronoi %26lt;b.txt %26gt;HEXAGON.txt");





now the problem is that I have another c++ code in windows and I need to call "voronoi" in this code aswell but I don'y know how to do it. I have copied voronoi into the folder of this code but it doesnt work. Please help.

How to use a c++ exe file from linux in windows?
It is better to have the source code voronoi to make the program portable and faster, I should say. So I would recommend you finding another source code implementation for voronoi.





As indicated earlier, the executable formats are different in Windows and linux, so you would need to use to use an emulator like Cygwin. Using Cygwin, you can run linux executables in Windows environment.
Reply:Don't. Linux uses the ELF file format for its executables. Windoze uses the exe and com formats for its executables. If you want to run voronoi under Windoze you copy the source code to your Windoze HD and download either djgpp or DevC++ (at http://www.delorie.com/djgpp and http://www.bloodshot.net/dev-cpp.html ) and recompile it as an exe file. Both are Windoze ports of GCC.





If your computer can ever ever forgive you for leaving Windoze on it, it will thank you for not mixing file formats that way.
Reply:At a guess I say the problem was to do with the '/.' part of you system command. Windows and Linux will treat this differently. With the syntax you've used I think it would try to find voronoi in the the root directory of the current drive.





I'd copy voronoi into some directory that is in PATH and then call it with -





system ("voronoi %26lt;b.txt %26gt;hexagon.txt");





I create a C:\Bin folder to do this.

gerbera

Extract or View C++ Source code from an exe file?

Is there any way I can extract or at least the C++ source file of an exe file. Im really in need of help Iv only got the exe file and iv lost the source code. Please Some one Help.

Extract or View C++ Source code from an exe file?
A simple answer would be, No. You cannot extract the c++ source files (.cpp) from an .exe.





You can reverse engineer the binary file. You can always get the Assembly Source code (hopefully). Cause an EXE is a binary compilation. So you cannot get the .cpp files only the assembled code which is ASSEMBLY.





You could either DEBUG the exe and see the application run in Assembly, or use some kind of reverse engineering tool like DA.PRO





Take a look at Assuming its .NET:


http://www.netdecompiler.com/index.html


http://www.junglecreatures.com





It is illegal to get the source code of an EXE. Cause if the programmer wants the user to see the source code, he could of included it. Unless your learning how to crack software, then your doing something which isn't good.
Reply:No. Once a high-level language program is compiled into the assembly code, the information of the original source is lost. You cannot get back to the source code.





There is no one-to-one relationship between a high-level language statement and an assembly instruction. One statement is normally compiled to more than one instructions. Then the compiler attempt to optimize the code by removing redundant code, or replacing a code segment with better instructions.





So, why you cannot reverse engineering back the source? First, you do not know where the boundaries of two high-level languages are. Second, after optimization, you don't even have instructions for a complete statement anymore.
Reply:no.


C++ file I/O question?

My problem is I have to compute an average of grades from students from a text file and put the original data plus the averages in a new file. Each line of the input file contains a student's last name, a space, the student's first name, a space, and then ten quiz scores (whole numbers) separated by spaces all on one line. The data of the input file will be exactly the same as the input file, except there will be an average at the end of each line.





I have all the general open input file, output file, etc. stuff...I just don't know how to begin on the rest of it.

C++ file I/O question?
#include %26lt; fstream%26gt;





int main()


{





//open the file


ifstream in;


in.open("file.txt");





//open the output file


ofstream out;


out.open("out.txt");





//declaration


string firstname;


string lastname;


double score;


double sum = 0;


int n =1;





while (!in.eof())


//while it is not the end of file


{


// get the last name, first name and score in each line


in %26gt;%26gt; lastname %26gt;%26gt; firstname %26gt;%26gt; score;





//print in the output file the last name, first name and score


out %26lt;%26lt; lastname %26lt;%26lt; " " %26lt;%26lt; firstname %26lt;%26lt; " " %26lt;%26lt;score %26lt;%26lt; " ";





//print the average


sum = sum + score;


out %26lt;%26lt; sum / n %26lt;%26lt; endl;


n++;


}





//close the file


in.close()


out.close();





}// end of main


Is a C executable file portable across various systems?

how to create an installable file from a C program.

Is a C executable file portable across various systems?
No.





The source code will sometimes be portable, especially between different POSIX systems, but you still need to recompile for different CPU instruction sets.


Does we need turbo c software to run turbo c exe file?

Hmmm sounds wierd! I wrote a program called chart.c in turbo c which is two header files like bimap.h ,xyz.h.When I compile,chart.exe is created.when i run chart.exe in some other machine, its not running unless tc sofware and those two header files is placed in the system.Can anyone tell me why it happens and how to make one single exe file without all these headerfiles and tc sofware.





Thanks in advance

Does we need turbo c software to run turbo c exe file?
I think u may have to carry only the two header files.
Reply:kumarango... when you compile your code you must use independent source library. so when you compile the source the code will have certain flags and library built in. Assembler pointer must be made at start of your code.
Reply:Once you have your .exe file you should be able to execute it on any PC. You don't need to copy all the other files, they are just needed from your compiler to build the .exe file.
Reply:Your header file might be compiled as an extended object library of your exe file. This means that whenever you run chart.exe, it will look for its extended library which are your header files. To solve this, check your header decleration.
Reply:you need to make sure that it compiles those two header files inside the .exe file

rosemary

Need site for C, C++ ,Batch file programming?

i need a site where they teach advanced batch file programming, C, C++ and that kind of stuff properly.I Know the basics and need to study the advanced stuff becoz iam too sleepy to listen to the crap they teach in highschool.......

Need site for C, C++ ,Batch file programming?
Hehe..Sammy U'll never change yaar..:)


How can i retrieve .c source file from an exe file?

i was finishing my project and accidentaly overwrite the .c and all i have is executable file from the compiler, pls i badly nid help hir...can i decompile the executable to make c source? please help..

How can i retrieve .c source file from an exe file?
What you are looking for is called a "reverse compiler".





I have heard of them.





This may be one:


http://www.backerstreet.com/rec/rec.htm





Otherwise you are, indeed, out of luck.





If you stay in programming long enough, you will overwrite many files and each one will re-remind you to, "back up, back up, back up".
Reply:This just cannot be done since the compiler passed through various stages on the way to the EXE file. During each stage information is lost. So it is one way.


The only thing I think can be done is disassemble but it will not produce C but the assembley language
Reply:Some free utilities to do disassembly exist. Some for assembly to C exist. However, they will NOT recover variable names, strucutre names, comments and other declarations in any way other than the convention of the decompiler/disassembler. So, what you'll get will be really strange looking code, with nothing familiar in it. I've seen programmers try and pull this trick with there own code and still not recreate it very well. The site below has a variety of such tools, but if I were you, I'd just start over. It'll be easier and probably improve your knowledge more than disassembling it would any way.


EDIT --


There is one glimmer of hope that may help you out. You say that you "overwrite" the file? On some medium, such as floppy or hard drive, you might be able to use a data retrieval utility to find the magnetic remanants of the file's image. Just because the file is truncated, overwritten once or "deleted" doesn't mean that it is physically gone, it just can't be found and read by the computer's normal methods. Try searching for a free demo of the software.


I wish you luck.
Reply:If only, if only. Sorry.
Reply:Yes, you can use a "DEcompiler" that will generate C code from the exe. However, it will not look like the C code you wrote because a program looks at the machine instructions and produces C statements from those instructions. So it might help you start over, but the output from the decompiler is messy to read.
Reply:No, source code is not stored in the executeable file. As others have mentioned, you could use a decompiler ... but if you weren't backing up your data externally, then I'm guessing your project is not worth the trouble/effort of attempting to recover source code.





Sorry ... you'll need to write it again.


A C++ header file ???

Hello !





Does anyone know where I can find the definition, I mean, the code, of %26lt;strstream%26gt;, or if at all it can be found ? It's an old C++ header file, with four deprecated classes, but I need it because this thing I am trying to build uses it and it is also old :)





I am not very experienced with this :)





Thanks !

A C++ header file ???
If you have a C++ compiler installed on your machine (like Visual Studio), then the "include" path usually has all the header files. I have Visual Studio myself, so I searched under Program Files\Microsoft Visual Studio 8\VC\Include and found the file there. Y! Answers does not let me attach a file, otherwise I could have given you the file itself.
Reply:It would be part of an older version compiler distribution. I've updated all %26lt;strstream%26gt; code to use %26lt;sstream%26gt; with very little effort. Depending how much its used in your project, maybe that would be easier than finding a now discontinued header.





The difference is that %26lt;strstream%26gt; uses a character array for storage and %26lt;sstream%26gt; uses a std:string for storage. I've always used them for output formatting so all I had to do was change the type and use c_str() to get a usable character array result.
Reply:# include %26lt;iostream.h%26gt;
Reply:I do not quite understand your question.





Did you check this website out below?





http://www.tacc.utexas.edu/services/user...





It has extensive information concerning the class strstream, what it is used for (writing to an array located in memory), and other information.
Reply:Use google code search, the best way to find out about google code search is to google it :)
Reply:strstream is still available in Visual Studio 2005. The class stringstream is part of the STL and should be available to most compilers on most platforms.
Reply:Do you have Microsoft Visual Studio 2005? The latest version (2008 isnt out yet) has access to the MS library which has a lot of the most-used files for programming.





%26lt;strstream%26gt; doesn't sound familiar, if it is old, it might be built into %26lt;string%26gt;
Reply:%26lt;strstream%26gt; translates to strstrea.h


Do a search in your compiler directory for this file.


C++ data file on mac?

I am trying to write a program in C++ that will take input from a data file (employee.in). In the book (from school) it only explains how to run this program using a MS-DOS input window. I don't think I can run that on my mac computer. Does anyone know how to run this program on a mac? Or... Does anyone know how to run the MS-DOS promt on a mac? Thanks.

C++ data file on mac?
if u can istall c++ program on ur computer that would do it for u try may be dev c++
Reply:You have a C compiler on the mac. Once compiled for mac it will run from the console window. The commands are different, and it would need re-compiling for Windows use.
Reply:you can run windows on macs... and work on the file from windows on the mac. you would need a pretty fast mac.... somewhat new... bootcamp or parallels, and of course a windows cdrom.





this is the only way to have msdos on a mac.

wallflower

What is the C:/RECYCLER file for?

I have a problem with some files that I've downloaded from a P2P network. They keep on leaving duplicates of a song that I've downloaded and when I click on them they don't play. The file path says C:/RECYCLER/NPROTECT/(somenumbers).mp3.


When I went to this location, there were a bunch of files that were encoded and I look and see that the attributes of the NPROTECT file say "Hidden". Is this why I cannot delete the faulty mp3s? Thanks.

What is the C:/RECYCLER file for?
This folder is part of Norton antivirus. You can limit the size of this file by cutting back on the amount of restore points you create. When you uninstall Norton you can delete this folder. As to the encoded files they are probably backups of files you've been downloading.





check out these sites for more info... http://www.wilderssecurity.com/showthrea...


http://help.lockergnome.com/general/NPRO...








hope this helps or at least gives you a starting point.
Reply:RECYCLER is the RECYCLE BIN folder





it is the folder where deleted files are temporarily stored (i.e. "Are you sure you want to send %26lt;file%26gt; to the Recycle Bin?")





Every hard drive installed in your computer has its own RECYCLER folder.





To delete those faulty MP3s in the Recycled folder, try to empty your Recycle Bin.
Reply:C:\Recycler is one more Microsoft implementation to either guard a legitamate user from harming his or her system, or to collect data for a purpose known only to Microsoft.





The C:\Recycler folder on a Windows Operating System is where all the deleted files go. If you go to "Tools%26gt; Folder Options...%26gt; View %26gt;" in a explorer window and uncheck "Hide protected Operating System Files" you will be alerted with a box saying it is un davised to do this. Click ok and navigate to C:\ drive and you will see it and be able to navigate and delete the files.





hope this helps.
Reply:Bet you set the p2p software to delete incomplete or faulty files. And somewhere along the line you have used Norton utilities?? Right? Norton protected recycle bin is a pain in the a@s. Hard to get rid of but it can be done. Go to the Norton control and turn off Norton protected recycle bin. Also get "file utilities" from http://www.gibinsoft.net/gipoutils/ once installed it lets you move or delete on reboot when windows cant screw with you.