C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 29th, 2012, 09:00 AM
Nick Wyden Nick Wyden is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 44 Nick Wyden Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 4 h 10 m 54 sec
Reputation Power: 0
Declaring a Literal

Hello I am still very new to objective C and I was wondering how do you declare a variable to be a string literal. For example if the variable is an integer you would write

int example;


and if the variable had a decimal you would write

float example;

but what about if it is a piece of literal text?

Reply With Quote
  #2  
Old January 3rd, 2013, 03:12 PM
admiraln admiraln is offline
Still Learning
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Location: Montreal, Canada
Posts: 55 admiraln User rank is Sergeant Major (2000 - 5000 Reputation Level)admiraln User rank is Sergeant Major (2000 - 5000 Reputation Level)admiraln User rank is Sergeant Major (2000 - 5000 Reputation Level)admiraln User rank is Sergeant Major (2000 - 5000 Reputation Level)admiraln User rank is Sergeant Major (2000 - 5000 Reputation Level)admiraln User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 18 h 57 m 51 sec
Reputation Power: 38
you should search for the keywords i your question before you ask it.

I found
http://blog.bignerdranch.com/398-objective-c-literals-part-1/

Reply With Quote
  #3  
Old January 3rd, 2013, 03:53 PM
clifford's Avatar
clifford clifford is offline
Contributing User
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Aug 2003
Location: UK
Posts: 4,824 clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level)clifford User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 21 h 1 m
Reputation Power: 1800
You must first understand that there is no built-in data type in either C, C++ or Objective-C. Unlike C however C++ and Objective-C standard libraries provide standard string classes that essentially add a string type. In C a string is merely a convention using a character array with a nul terminator, which is supported by a library for performing operations such as assignment and comparison.

I am no Objective-C expert and find the language syntax arcane and the documentation unfathomable, however I believe that this may be what you are after.

The pedant in me feels the need to clarify some terms used in your question:

A float does not represent a decimal, it represents an approximation of a real number (as opposed to an integer) using a binary representation. That representation is typically a binary-floating-point representation and as such there are many decimal values that it cannot precisely represent. There are decimal-floating-point representations that can accurately represent decimal values, but there is no built-in type in Objective-C for that, and most underlying FPU hardware does not directly support it, so it is intrinsically slower. C# is one language that does have a decimal data type.

A "literal" is a direct value rather than a variable, so "declaring a literal" is an oxymoron. For example "ABC123" is a string literal, 12345 is an integer literal.

I believe that what you intended to ask is how you can declare a variable of string type, or possibly how to declare a variable and assign or initialise it with a string literal?

Last edited by clifford : January 3rd, 2013 at 03:57 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > Declaring a Literal

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap