chiguy's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
Members
Active Posts:
40 (0.04 per day)
Joined:
17-October 10
Profile Views:
398
Last Active:
User is offline 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
Icon   chiguy has not set their status

Posts I've Made

  1. In Topic: Debugging question

    Posted 14 Jun 2012

    View Postmodi123_1, on 14 June 2012 - 11:46 AM, said:

    *sigh* Okay no.. You have your websolution folder... you know the thing with all the broken out codebehind and solution files? *NOT* the compiled bin, dlls, and junk you would deploy. You want the solution folder!



    Ahhhhh okay. Thank you, I get it now.
  2. In Topic: Debugging question

    Posted 14 Jun 2012

    View Postmodi123_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
  3. In Topic: Printing a line from a file onto the screen.

    Posted 3 Apr 2012

    View Postjimblumberg, 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.
  4. In Topic: Printing a line from a file onto the screen.

    Posted 3 Apr 2012

    View Postvividexstance, 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

    View Postjimblumberg, 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


    View Postr.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
    �
    
    


    View Postr.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!
  5. 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.

Comments

chiguy has no profile comments yet. Why not say hello?