473,378 Members | 1,412 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

chars

OK this thing about chars. So a string and a char is two different
things. This is the way I'm understanding things:

char c; is actually a short or int
char *s; s is a pointer to a char and to be used for strings
char foo[5]; is an array used to store so much info.

Do I sound like I'm getting it right now?

Bill


Jan 7 '08 #1
5 1797
Bill Cunningham wrote:
OK this thing about chars. So a string and a char is two different
things. This is the way I'm understanding things:

char c; is actually a short or int
No. A char is a char. That is one integer type in C. short is another.
int is another. They are not the same types.
char *s; s is a pointer to a char and to be used for strings
It can be set to point to a string. It doesn't need to. This is
perfectly valid C:

char *s;
char c = 'A';

s = &c;

*s = 'B';

It could set to point to a string literal:

s = "string";

However, that is bad programming practice.

It could point to allocated storage, that might contain a string:

s = malloc(5); /* skipping error check */
strcpy(s, "Hi!");
char foo[5]; is an array used to store so much info.
It is an array of char. It might hold string. It would limited to a
string length of four.
Do I sound like I'm getting it right now?
Reply hazy, check again later.

Brian
--
Please don't top-post. Your replies belong following or interspersed
with properly trimmed quotes. See the majority of other posts in the
newsgroup, or:
<http://www.caliburn.nl/topposting.html>
Jan 7 '08 #2
> Do I sound like I'm getting it right now?

Reply hazy, check again later.
http://www.eskimo.com/~scs/cclass/notes/sx10g.html
Jan 7 '08 #3
Bill Cunningham wrote:
>
Do I sound like I'm getting it right now?
Reply hazy, check again later.
http://www.eskimo.com/~scs/cclass/notes/sx10g.html

What about it?


Brian
Jan 7 '08 #4

"Default User" <de***********@yahoo.comwrote in message
news:5u*************@mid.individual.net...
Bill Cunningham wrote:
>>
> Do I sound like I'm getting it right now?

Reply hazy, check again later.
http://www.eskimo.com/~scs/cclass/notes/sx10g.html


What about it?


Brian
I was just letting you know where I am getting my information.

Bill
Jan 7 '08 #5
Bill Cunningham wrote:
>
"Default User" <de***********@yahoo.comwrote in message
news:5u*************@mid.individual.net...
Bill Cunningham wrote:
>
Do I sound like I'm getting it right now?

Reply hazy, check again later.

http://www.eskimo.com/~scs/cclass/notes/sx10g.html

What about it?
I was just letting you know where I am getting my information.
Well, that's a decent tutorial. Whether you're getting it or not is
another question (hence, "reply hazy").


Brian
Jan 7 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jonas Meurer | last post by:
hello, my script selects a comment saved as VARCHAR in MySQL and displays it inside an html page. the problem is, that the comment contains several special characters, as mysterious utf-8...
8
by: Nick | last post by:
Hi ! I want to load an old Pascal-Dos-File where records stand in. When i view the file in a HEX-Editor it's clear how to acces these Strings and chars in that file. Since these are old 8BIT...
8
by: Nikolay Petrov | last post by:
I need a way to strip chars from a string. The chars are all chars that are not allowed in file path. TIA
6
by: guy | last post by:
if a string contains surrogate chars (i.e. Unicode characters that consiste of more than 1 char) do functions that use an indexer or a string length into the string e.g. Mid, Len work correctly? ...
7
by: Edward Elliott | last post by:
I'm looking for the "best" way to strip a large set of chars from a filename string (my definition of best usually means succinct and readable). I only want to allow alphanumeric chars, dashes,...
1
by: tomtiv | last post by:
Hi All, I am having a probem with asp, xml, com while using chinese chars. The chinese letters come out of com fine and they are also fine when i use asp to write to a text file. When i load...
9
by: kaustubh.deo | last post by:
I am facing issues printing french chars like using printf function. I have reproduced this issue with simple C program as follows. #include <stdio.h> #include <locale.h> int main(int...
0
by: Yobbo | last post by:
Hi All I have an ASP function in place to strip invalid chars out of a data store before I create an XML file of this data, but my function doesn't work on a certain set of chars. As far as I...
6
by: Christoph Zwerschke | last post by:
In Python programs, you will quite frequently find code like the following for removing a certain prefix from a string: if url.startswith('http://'): url = url Similarly for stripping...
13
by: Hongyu | last post by:
Hi, I have a datetime char string returned from ctime_r, and it is in the format like ""Wed Jun 30 21:49:08 1993\n\0", which has 26 chars including the last terminate char '\0', and i would...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.