|
Try this:
char* my_strdelupper(char* s){
int i, len;
char* sl;
len = strlen(s);
sl = (char*)malloc(len+1); i = 0; while (*s != '\0'){
if (!isupper(*s)){
sl[i++] = *s; }
s++;
}
sl[i] = '\0';
printf("%s\n", sl);
return sl;
}
|
|
|
|
|
The stupid thing is that I can't use malloc, so I made a char array with fixed size to overcame that problem.
|
|
|
|
|
Thank you, for all, it was a great help.
The problem was solved by:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define false 1
#define true 0
char* my_strdelupper(char* s){
int i,j, len;
char aux[100];
char debuging;
len = strlen(s);
j = 0;
for (i = 0; *(s + i) != '\0'; i++){
if (!isupper(*(s+i))){
debuging = *(s + i);
*(aux + j) = debuging;
j++;
}
}
*(aux + j) = '\0';
strcpy(s, aux);
return s;
}
int main()
{
char s3[]="Maria, TU sabes que TU éS o meu \"Grande Amor\"";
printf("%s\n",my_strdelupper(&s3[0]));
return 0;
}
|
|
|
|
|
As a note - you define 'len' but you don't use it.
Presumably the assignment does not say otherwise, using that would make your code simpler.
|
|
|
|
|
Note you don't need extra storage, the function may change the string in place:
char * remove_upper( char * s)
{
char * p, *q;
for (p = q = s; *p != '\0'; ++p)
if ( ! isupper(*p) )
*q++ = *p;
*q = '\0';
return s;
}
|
|
|
|
|
Taken from K&R 1st ed? Certainly has that feel>
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
It is the Wonderful C programming language, of course has such a feel.
In any case, were Dennis and Brian the ones who plagiarized my programs. 
|
|
|
|
|
I was begging to think no one here was thinking.
Thanks
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence." - Edsger Dijkstra
"I have never been lost, but I will admit to being confused for several weeks. " - Daniel Boone
|
|
|
|
|
I have copied a program from CrazyGeeks website and modified some of its statements. Anyone please tell me whats wrong in below code:
#include <iostream>
using namespace std;
int main()
{
int count, j, elements[50], search_num, first, last, mid;
cout<<"Enter the total number of elements :";
cin>>count;
cout<<"\nEnter ">>count>>" numbers:\n";
for (j=0; j<count; j++)
{
cin>>elements[j];
}
cout<<"\nWhich number that you want to search: ";
cin>>search_num;
first = 0;
last = count-1;
mid = (first+last)/2;
while (first <= last)
{
if(elements[mid] > search_num){
first = mid + 1;
}
else if(elements[mid] == search_num){
cout<<search_num<<" found in array at "<<mid+1<<"\n";
break;
}
else {
last = mid - 1;
}
mid = (first + last)/2;
}
if(first > last){
cout<<search_num<<" Not found in an array";
}
return 0;
}
Code link
|
|
|
|
|
Quote: cout<<"\nEnter ">>count>>" numbers:\n";
Should be
out << "\nEnter " << count << " numbers:\n";
You should ask the user for an ordered sequence, in order to make the binary search work.
Your code is very C -like, you didn't take advantange of the wonderful features of modern C++ . 
|
|
|
|
|
|
|
You should format your code snippet with the proper indentations.
|
|
|
|
|
Hi!
I am currently working on a project that is used to the global event.
I did not find any vague suggestions on google.
Show me how to start it and document it.
Thank you!
|
|
|
|
|
I'm having diffculty to understand what you're looking for, and I suspect for google it's the same.
Let's start with specifiying more clearly what you want to do:
- what is a typical usecase for the program that you want to solve?
- what are the conditions under which the program is used?
- who uses the program?
- who writes the program (other than you)?
And more to the point:
- what do you mean by global event?
- what do you mean by 'start' and 'document' and 'it'
I do have some ideas what you're talking about, but it would be easier to offer meaningful advice when there's less guessing involved.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
Thanks for your answer!
I'm looking to build a demo to use to the global event.
I want to write a program (MainApp) that manages two other programs (SubApp1 and SubApp2). When I run MainApp, then MainApp will start subapp1 and subapp2.
|
|
|
|
|
1. You still haven't told us what you mean by global event
2. You're talking about processes and threads. Typically when you start an application on your computer, this starts a process with a single thread, the main thread. You can choose to leave it at that, in which case your program will just sequentially process it's task. Or your process can create new threads controlled by it, which will potentially run in parallel. You can also start a new process from the first one, but then your initital process will have no direct control over it; it can only talk to it via interprocess communication protocols.
In that latter case, communication might be implemented by sending Windows Events to the other process. I'm sure there are many other ways, but I'm not up to date with modern approaches in this field, nor do I have any relevant experience.
So, when you talk a 'mainapp' and 'subapp's, do you mean a process and it's threads, or do you mean to spawn separate processes - in which case the term 'subapp' would be very misleading?
P.S.: I only now spotted your answers below - looks like I was on the wrong path all along. As CPallini said, you'd better ask at the Kentico forums. And as they're using C#, the question is if you really want to go the extra mile of trying this in C++ ...
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
Thank you very much for your support!
|
|
|
|
|
What event your are talking about?
Event Objects[^], for instance, as far as I know, are not globals.
|
|
|
|
|
|
You should have mentioned you were using Kentico12. Probably you need to ask the question here: Questions & Answers[^].
In any case it looks .NET stuff, not C++ .
|
|
|
|
|
|
|
I took a quick glance at the Kentico site. Now I know this is about designing web pages - another bit of information you could have shared from the start.
One thing however is important to know: on it's main page[^] Kentico states (under "Disadvantages") that itQuote: Requires knowledge of ASP.NET MVC and programming. This doesn't sound like a beginner's tool to me. If you don't already know ASP.NET, this will be a stony path...
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
I am trying to open any kind of file using
ShellExecute(NULL, _T("open"), sPath + _T("\\") + sText, NULL, NULL, SW_SHOWNORMAL);
and is working well, but there a little issue: when I am trying to open an image file, I get always the "How do you want to open this file" dialog, everytime … why ? Of course, when I am trying to open this kind of image file from y windows explorer, is open with my default program, Windows Photo Viewer.
Is there any kind of parameters to put on ShellExecute ? Please note that I use this for ever kind of file, including exe files.
|
|
|
|