16,022,413 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Aamir Yousafi (Top 16 by date)
Aamir Yousafi
13-Aug-16 15:51pm
View
Yeah, but with such small programs, the running time won't be significant anyway. The profiler will, hopefully, tell me something about the processor operations completed. This will help me analyze which of my algorithms is most efficient, since I cannot rely on the standard math available for each type of algorithm, because I didn't copy - paste that code and implemented quite a bit differently than the standard.
Aamir Yousafi
13-Aug-16 13:19pm
View
It's not only runtime that I need. In fact, when I run the .exe in Windows, I get the execution time in the MS-DOS console.
Yes, I need more details. I'll look into a good profiler.
Aamir Yousafi
13-Aug-16 6:56am
View
So, actually, if you have a way to fix that quicksort function so that it doesn't need to create new arrays, which I was trying to avoid doing, then I would love that. Let me know if you want me to share that code.
Aamir Yousafi
13-Aug-16 6:54am
View
ppolymorphe, yes, you're probably right about the dynamic memory allocation. I'm going to use that from now on for all my arrays whether or not they are linked lists.
Regarding the array / pointer being passed to the function, well, my experience is that if you're passing a pointer, you should pass it as such and when you're passing an array, you pass it as such. I remember getting frustrated with my quicksort algorithm code for recursive calls when I was trying to pass pointers that would work on the arrays because it was crashing. Finally, when I changed all of those pointers to arrays that would be recursively declared and passed to the quicksort function recursively, I got it to work. I can share my quicksort code with you so you know where I'm coming from on this.
Aamir Yousafi
19-Jul-16 13:06pm
View
Thanks. I will incorporate that into my program(s).
Aamir Yousafi
19-Jul-16 13:05pm
View
thanks
Aamir Yousafi
19-Jul-16 12:43pm
View
What do you mean "line by line"? The debugger only points out where the segmentation fault happens. How do you execute the program line by line using the debugger?
Aamir Yousafi
15-Jul-16 9:05am
View
Well, CPallini, I'm not using C++ right now so that's why I'm not going to get into this right now. I'll save this for the future (near future, probably). Thanks.
Aamir Yousafi
15-Jul-16 9:03am
View
but virtual box is a Windows application, right? How would I work on C from that environment?
Aamir Yousafi
15-Jul-16 2:09am
View
I am using the GCC compiler on a Windows 64-bit system. Yes, I've heard that the C implementation on my type of computer sets RAND_MAX to 32768 and there's no way to change it. Your computer is a Linux. I've heard that C works most perfectly in Linux. It's not practical or affordable for me to purchase a Linux-based OS yet. And my computer is a laptop, Acer V5-571g, probably not dual-bootable.
Aamir Yousafi
24-Jun-14 5:23am
View
Okay. Thanks again for all advice and I have fixed issues and the program works except for one issue: after the characters are reversed, there is junk left, if i run the program a second time from the command prompt. Plz see the code below:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
main()
{
/* pre-run-time declarations */
unsigned int dynlen = 256;
int i = 0, ch = 0, j = 0;
char *strng = (char*)malloc(dynlen);
printf("\nPlease enter a simple phrase with no spaces: "); // ask for input
/* take input of unknown string size from user and allocate and reallocate so that no memory is wasted */
while((ch = getchar()) != '\n')
{
strng[i] = (char)ch;
i++;
if(i == dynlen)
{
dynlen += 256;
strng = (char*)realloc(strng, dynlen);
}
}
strng = (char*)realloc(strng, i+1);
strng[i] = '\0';
/* fill in character by character the new array with the old array's characters in reverse order */
char *strng2 = (char*)malloc(i+1);
i--;
while(i >= 0)
{
strng2[j] = strng[i];
i--;
j++;
}
printf("\nThe following is the phrase you entered backward: %s\n", strng2); // displays new string
/* free memory */
free(strng);
free(strng2);
}
Aamir Yousafi
14-Jun-14 10:11am
View
Sorry for the late response. Your help is much appreciated.
Aamir Yousafi
7-Jun-14 10:49am
View
after the user inputs the character string in *strng, that pointer will be pointing to the null terminator, so after moving strng back one, it will be on the last real character of the string. ANd then with *strng2 = *strng, I set what strng2 is pointing to equal to what strng is pointing to, and then the rest of the code. I don't get what's wrong with this line, logically or in terms of syntax ...
Aamir Yousafi
6-Jun-14 9:49am
View
when debugging, I'm getting the error SIGSEGV segementation fault
Aamir Yousafi
6-Jun-14 9:24am
View
the debugger doesn't tell me anything because this code compiles just fine. The only issue is that it freezes as soon as I input anything
Aamir Yousafi
31-May-14 5:53am
View
this shoudl read "#include <stdio.h>"
Show More