LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-25-2005, 04:47 AM   #1
lazyuser
LQ Newbie
 
Registered: May 2004
Location: US
Distribution: Debian - Sarge
Posts: 15

Rep: Reputation: 0
Quotation marks and strings - in C


Hello,
I writing a program, and I don't know how to insert quotation marks in my code.
For example,
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
        char url[100] = "http://www.google.com";

        printf("%s", url);
        printf("\n");

        return 0;

}
How would I get url, to store "http://www.google.com", and not http://www.google.com.

Any help would be appreciated.

Lazyuser
 
Old 01-25-2005, 04:50 AM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
You have to put in an escape sequence to get a literal double-quote:
Code:
char url[100] = "\"http://www.google.com\"";
 
Old 01-25-2005, 04:59 AM   #3
lazyuser
LQ Newbie
 
Registered: May 2004
Location: US
Distribution: Debian - Sarge
Posts: 15

Original Poster
Rep: Reputation: 0
Thank you for your quick reply, and it worked.
Thanks
Lazyuser
 
Old 01-25-2005, 05:25 AM   #4
lazyuser
LQ Newbie
 
Registered: May 2004
Location: US
Distribution: Debian - Sarge
Posts: 15

Original Poster
Rep: Reputation: 0
Hello, I have a new problem, if anybody can help.
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
        char url[35] = "\"http://www.google.com\"";


        execl("/usr/bin/wget", "wget", url, 0);


        return 0;

}
When I try to run this program, I get the following error.
--04:21:04-- ftp://%22http//www.google.com%22
=> `www.google.com"'
Resolving %22http... failed: Host not found.
Why is it adding %22 to my code. When I print it, it works. 22 in hex, is the quotation marks, why is it changing them. It compiles fine.
Lazyuser
 
Old 01-25-2005, 05:59 AM   #5
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
sounds like wget is translating the chracters to me.
 
Old 01-25-2005, 08:14 AM   #6
zaichik
Member
 
Registered: May 2004
Location: Iowa USA
Distribution: CentOS
Posts: 419

Rep: Reputation: 30
You wouldn't need the double quotes in the argument, would you?
Code:
[root@inet root]# wget http://www.google.com
--08:06:48--  http://www.google.com/
           => `index.html'
Resolving www.google.com... done.
Connecting to www.google.com[64.233.167.104]:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]

    [ <=>        ] 2,014          1.92M/s

08:06:48 (1.92 MB/s) - `index.html.1' saved [2014]

[root@inet root]#
Try it without and see if that works.

Last edited by zaichik; 01-25-2005 at 08:15 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Execvp With Quotation Marks amitbern Programming 10 11-25-2005 10:28 AM
no quotation marks jdoe9898 Linux - Newbie 1 10-12-2005 03:07 AM
trouble with quotation marks in c-shell script mathias1979 Linux - Newbie 1 05-30-2005 10:16 AM
Quotation Marks Linux / Firefox jjdoll42 Linux - Software 6 04-19-2005 10:13 AM
quotation marks donīt display in X Obi-Wan_Kenobi Slackware 1 08-31-2003 10:42 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration