Thread: Need help please with string

  1. #1
    Registered User
    Join Date
    Apr 2016
    Posts
    21

    Need help please with string

    Code:
    #include <stdio.h>
    int main(void)
    {
    
    
            FILE *fp = NULL;
    
    
            fp = fopen("index.html" ,"a");
            fprintf(fp,"<meta http-equiv="refresh" content="0; url=http://example.com/" />");   /* Need to insert this code to created file */
            (void)system("index.html");
    }
    Can't insert a html code in to created index.html its think that second part is comment

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    You need to "escape" the quotation marks that are embedded in your string. Put a \ character in front of each " character, except the first and last.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  3. #3
    Registered User
    Join Date
    Apr 2016
    Posts
    21
    Quote Originally Posted by Elkvis View Post
    You need to "escape" the quotation marks that are embedded in your string. Put a \ character in front of each " character, except the first and last.
    Thanks

  4. #4
    Registered User
    Join Date
    Apr 2016
    Posts
    21
    #include <stdio.h>
    #include<stdlib.h>
    int main(void)
    Code:
    {
    
    
            FILE *fp = NULL;
    
    
            fp = fopen("index.html" ,"a");
            fprintf(fp,"<meta http-equiv=\"refresh\" content=\"0; url=http://google.com/\" />");   // Need to insert this code to created file.
            int c = 1, d = 1;
            for ( c = 1 ; c <= 32767 ; c++ ) /*Delay */
            for ( d = 1 ; d <= 32767 ; d++ )
            {
    
    
            }
            puts("Run");
            (void)system("index.html");
    }
    This messages appears in console
    The process cannot access the file because it is being used by another process

    Sorry what kind of changes I must do to get it running please help and thanks a lot.

  5. #5
    Registered User
    Join Date
    Apr 2016
    Posts
    21
    #include <stdio.h>
    #include<stdlib.h>
    #include<windows.h>
    int main(void)
    Code:
    {
    
    
            FILE *fp = NULL;
    
    
            fp = fopen("index.html" ,"a");
            fprintf(fp,"<meta http-equiv=\"refresh\" content=\"0; url=http://google.com/\" />");   // Need to insert this code to created file.
            int c = 1, d = 1;
            for ( c = 1 ; c <= 32767 ; c++ )
            for ( d = 1 ; d <= 32767 ; d++ )
            {
    
    
            }
            puts("Run");
            ShellExecute(NULL,"open","index.html",NULL,NULL,SW_SHOWNORMAL);
    }

    Now its works.

  6. #6
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    You could try calling

    Code:
    fclose(fp);
    right before you try to "run" the file.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 05-01-2013, 10:11 PM
  2. Replies: 1
    Last Post: 04-27-2013, 04:36 AM
  3. Replies: 22
    Last Post: 07-28-2011, 01:26 PM
  4. Replies: 7
    Last Post: 06-16-2011, 06:21 PM
  5. Replies: 1
    Last Post: 10-31-2005, 11:36 AM

Tags for this Thread