![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jan 2008
Posts: 10
Rep Power: 0
![]() |
Help with a file
I am working on this program that is a hex dump. I have to use a file. I have it where it ask the user what file it is and they enter like test.txt and it opens and uses file test but I want to change it so that it does not ask the user. How would I do that. Here is what I have.
c++ Syntax (Toggle Plain Text)
|
|
|
|
|
|
#2 |
|
PFO God In Training
![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 549
Rep Power: 4
![]() |
Re: Help with a file
delete lines 5, 6 and 7 then set file_in_name to whatever you want
file_in_name = "test.txt"; |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Jan 2008
Posts: 10
Rep Power: 0
![]() |
Re: Help with a file
Now it is giving me an error.....c:\Documents and Settings\Owner\Desktop\program2\program2.cpp(32) : error C2440: '=' : cannot convert from 'const char [11]' to 'char [80]'
C++ Syntax (Toggle Plain Text)
|
|
|
|
|
|
#4 |
|
Programming Guru
![]() |
Re: Help with a file
This is what Ancient Dragon was telling you to do:
CPP Syntax (Toggle Plain Text)
|
|
|
|
|
|
#5 |
|
Newbie
Join Date: Jan 2008
Posts: 10
Rep Power: 0
![]() |
Re: Help with a file
thanks that helped
|
|
|
|
|
|
#6 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
Re: Help with a file
In C and C++, you can't assign an array to another array: you have to individually copy each element of the array from one to another. As a C-style string (which is what you're using) is simply an array of characters, you can't do this:
file_in_name = "test.txt"; strncpy(file_in_name, "test.txt", 79); |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| problem processing file into a char array | csrocker101 | C++ | 1 | May 8th, 2007 11:50 PM |
| add mutiple users to the smbpasswd file. | Pizentios | Bash / Shell Scripting | 3 | Oct 20th, 2005 12:48 PM |
| After execution - Error cannot locate /Skin File? | wchar | Visual Basic | 1 | Mar 5th, 2005 9:04 PM |
| airport Log program using 3D linked List : problem reading from file | gemini_shooter | C++ | 0 | Mar 2nd, 2005 4:12 PM |
| Structure char field to a disk file | ehab_aziz2001 | C++ | 0 | Feb 10th, 2005 2:42 PM |