chiguy's Profile
Reputation: 0
Apprentice
- Group:
- Members
- Active Posts:
- 40 (0.04 per day)
- Joined:
- 17-October 10
- Profile Views:
- 398
- Last Active:
Jun 14 2012 12:08 PM- Currently:
- Offline
Previous Fields
- Country:
- US
- OS Preference:
- Windows
- Favorite Browser:
- Chrome
- Favorite Processor:
- Intel
- Favorite Gaming Platform:
- Who Cares
- Your Car:
- BMW
- Dream Kudos:
- 0
Posts I've Made
-
In Topic: Debugging question
Posted 14 Jun 2012
-
In Topic: Debugging question
Posted 14 Jun 2012
modi123_1, on 14 June 2012 - 10:57 AM, said:You would have to have it output (to a textfile, a popup, etc) the string. That means you would need to add those options to your code and then redeploy it.
Typically you can get away with running the web solution on your local machine.
Yeah I'm trying to run it locally but it doesn't seem to work. I just copied the files to my local machine and opened them as a website in VS2010. When I click on any links they redirect but then dont load the page, I just get a blank page with a "Not Found" title.
Thanks -
In Topic: Printing a line from a file onto the screen.
Posted 3 Apr 2012
jimblumberg, on 03 April 2012 - 11:28 AM, said:What is the purpose of your file variable? Why do you try to create your file variable but then use prog_name to open the file?
That "ELF" in your output tells me you are opening the executable program not the source file.
Jim
That was the mistake... prog_name is the executable file that's being debugged. So by adding ".c" we can get the .c file and access the code. So that's why I'm using "file" to represent the source file- without editing prog_name as it is a global variable. -
In Topic: Printing a line from a file onto the screen.
Posted 3 Apr 2012
vividexstance, on 03 April 2012 - 11:16 AM, said:That while-loop isn't exactly the same as what jimblumberg posted above is it?
No it's not you're right- I will update it and try again. Thanks
jimblumberg, on 03 April 2012 - 11:17 AM, said:You need to allocate some memory for your file variable before you can place anything into it.
char* file; //filename char mychar; int i = 1; //for traversal purposes strcpy(file,prog_name);
Where and how is prog_name defined?
Please provide a complete program that illustrates your problem.
Jim
Ok thanks I'll try to allocate some memory for file. prog_name is a global variable that holds the program's name (minus the .c part) The complete program is quite large- it's a debugger project I'm working on. This portion prints a specific line of code from the .c file
r.stiltskin, on 03 April 2012 - 11:17 AM, said:You have to declare file as a char array big enough to hold the entire string including the extra .c and the terminating null char, not just a char* pointer.
Thanks I'll try that and post the result
I have updated the code to this:
FILE *fp; char line[500]; char* myline; int current_line = 0; char file[500]; char mychar; int i = 1; strcpy(file,prog_name); strcat(file, ".c"); fp = fopen(prog_name, "r"); if(fp == NULL) { printf("error reading file bro"); } else { //myline = fgets(line, 500, fp); while(fgets(line, 500, fp) != NULL && current_line < line_num) { printf("%s\n", line); current_line++; } //printf("%s \n", myline); } fclose(fp);
And the output remains the same....
ELF ����-��U �T��T$�$�������U������� �D$ �D$ �D$�|$ ~��D$ 5 �
r.stiltskin, on 03 April 2012 - 11:17 AM, said:And then, in fopen(), isn't file the complete filename that you want to use, rather than prog_name?
Wow, that was the problem!! Thank you for catching that, it works now. Awesome! -
In Topic: Printing a line from a file onto the screen.
Posted 3 Apr 2012
Sure, sorry. Here it is. Thanks
FILE *fp; char line[500]; char* myline; int current_line = 0; char* file; char mychar; int i = 1; strcpy(file,prog_name); strcat(file, ".c"); fp = fopen(prog_name, "r"); if(fp == NULL) { printf("error reading file bro"); } else { myline = fgets(line, 500, fp); while(myline != NULL && current_line < line_num) { myline = fgets(line, 500, fp); printf("%s\n", line); current_line++; } printf("%s \n", myline); } fclose(fp);
My Information
- Member Title:
- New D.I.C Head
- Age:
- Age Unknown
- Birthday:
- Birthday Unknown
- Gender:
-
Contact Information
- E-mail:
- Private
Friends
chiguy hasn't added any friends yet.
|
|


Find Topics
Find Posts
View Reputation Given
|
Comments
chiguy has no profile comments yet. Why not say hello?