473,326 Members | 2,148 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,326 software developers and data experts.

what is the difference between the declarations char *s and char s[]

i found with the use of char *s on subsequent calls memory fragmentation is happening...
but with char s[] its working fine...
can anybody help.
Jul 18 '07 #1
6 1400
Meetee
931 Expert Mod 512MB
i found with the use of char *s on subsequent calls memory fragmentation is happening...
but with char s[] its working fine...
can anybody help.
Hi,

You might have not deleted/freed the memory after use. That may cause this problem.

Regards
Jul 18 '07 #2
Hi,

You might have not deleted/freed the memory after use. That may cause this problem.

Regards

can you please tell me exactly how to use it???
Jul 18 '07 #3
Hi,

You might have not deleted/freed the memory after use. That may cause this problem.

Regards

moreover we are not allocating any memory.
Jul 18 '07 #4
Meetee
931 Expert Mod 512MB
can you please tell me exactly how to use it???
You are using C/C++? For each of them, there are different memory allocation method.
Jul 18 '07 #5
You are using C/C++? For each of them, there are different memory allocation method.

I am using C. can you please help me out.
Jul 18 '07 #6
Meetee
931 Expert Mod 512MB
I am using C. can you please help me out.
Expand|Select|Wrap|Line Numbers
  1. char * buf;
  2. buf = malloc(size);
  3. free(buf);
  4.  
Regards
Jul 18 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Michael | last post by:
Ok, I'm just checking i'm on the right lines: sorry if i make a mistake with any strict definitions of things in a .h , try and put: class declaration (prototype) relevant forward...
9
by: Vipul Jain | last post by:
Can any one please tell me what is the difference between global scope of an variable and file scope of an variable. Vipul
5
by: Hal Styli | last post by:
Hello, can anyone explain the difference between the above declarations and why anyone would stray from the first. Are the other 2 standard, couldnt find them in K&R2. Thanks, Hal.
48
by: Wade Yin | last post by:
Hi, What's the difference between: char *x="abcde"; and char y={"abcde"};
18
by: Matt | last post by:
Hi, I have a probelm here: If I declare: char *p="Hello";
10
by: tinesan | last post by:
Hello fellow C programmers, I'm just learning to program with C, and I'm wondering what the difference between signed and unsigned char is. To me there seems to be no difference, and the...
21
by: Niu Xiao | last post by:
I see a lot of use in function declarations, such as size_t fread(void* restrict ptr, size_t size, size_t nobj, FILE* restrict fp); but what does the keyword 'restrict' mean? there is no...
8
by: arun | last post by:
Hi all,, I want to know if there is any performance difference between the following sets of declarations. int i, j; and int i;
15
by: robert maas, see http://tinyurl.com/uh3t | last post by:
Here's the source: #include <stdio.h> #include <errno.h> main () { char* str = "9999999999"; long long int llin; char* endptr; /* Set by strtoll */ int nch; errno = 0; llin = strtoll(str,...
10
by: Ahmad Humayun | last post by:
Whats the difference between: char str1 = "wxyz"; char* str2 = "abcd"; I can do this: str2 = str1 but I can't do this: str1 = str2
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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...

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.